< Summary

Class:Imagini.Core.Internal.Native
Assembly:Imagini.Core
File(s):/home/razer/vscode-projects/project-grove/imagini/Imagini.Core/Internal/Native.Windows.cs
Covered lines:0
Uncovered lines:11
Coverable lines:11
Total lines:37
Line coverage:0% (0 of 11)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
.cctor()100%100%
QueryTimerResolution()100%100%
SleepAtMost(...)400%0%

File(s)

/home/razer/vscode-projects/project-grove/imagini/Imagini.Core/Internal/Native.Windows.cs

#LineLine coverage
 1using System.Runtime.InteropServices;
 2using System.Threading;
 3
 4namespace Imagini.Core.Internal
 5{
 6  public static class Native
 7  {
 8    public static class Windows
 9    {
 10      [DllImport("ntdll.dll", SetLastError = true)]
 11      private static extern int NtQueryTimerResolution(out uint MinimumResolution, out uint MaximumResolution, out uint 
 12
 13      private static readonly double threshold;
 14
 15      static Windows()
 16      {
 017        NtQueryTimerResolution(out uint min, out uint max, out uint current);
 018        threshold = max * 0.0001 + 1;
 019      }
 20
 21      private static double QueryTimerResolution()
 22      {
 023        NtQueryTimerResolution(out uint min, out uint max, out uint current);
 024        return current * 0.0001;
 25      }
 26
 27      public static void SleepAtMost(double ms)
 28      {
 029        if (ms < threshold)
 030          return;
 031        var sleepTime = (int)(ms - QueryTimerResolution());
 032        if (sleepTime > 0)
 033          Thread.Sleep(sleepTime);
 034      }
 35    }
 36  }
 37}