Stopwatch.IsHighResolution 필드

정의

타이머가 고정밀도 성능 카운터를 기반으로 하는지 여부를 나타냅니다. 이 필드는 읽기 전용입니다.

public: static initonly bool IsHighResolution;
public static readonly bool IsHighResolution;
 staticval mutable IsHighResolution : bool
Public Shared ReadOnly IsHighResolution As Boolean 

필드 값

예제

다음 예제에서는 타이머의 빈도 및 해상도를 Stopwatch 표시합니다. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 Stopwatch 클래스입니다.

void DisplayTimerProperties()
{
   // Display the timer frequency and resolution.
   if ( Stopwatch::IsHighResolution )
   {
      Console::WriteLine( "Operations timed using the system's high-resolution performance counter." );
   }
   else
   {
      Console::WriteLine( "Operations timed using the DateTime class." );
   }

   Int64 frequency = Stopwatch::Frequency;
   Console::WriteLine( "  Timer frequency in ticks per second = {0}", frequency );
   Int64 nanosecPerTick = (1000L * 1000L * 1000L) / frequency;
   Console::WriteLine( "  Timer is accurate within {0} nanoseconds", nanosecPerTick );
}
public static void DisplayTimerProperties()
{
    // Display the timer frequency and resolution.
    if (Stopwatch.IsHighResolution)
    {
        Console.WriteLine("Operations timed using the system's high-resolution performance counter.");
    }
    else
    {
        Console.WriteLine("Operations timed using the DateTime class.");
    }

    long frequency = Stopwatch.Frequency;
    Console.WriteLine("  Timer frequency in ticks per second = {0}",
        frequency);
    long nanosecPerTick = (1000L*1000L*1000L) / frequency;
    Console.WriteLine("  Timer is accurate within {0} nanoseconds",
        nanosecPerTick);
}
Public Shared Sub DisplayTimerProperties()

   ' Display the timer frequency and resolution.
   If Stopwatch.IsHighResolution Then
      Console.WriteLine("Operations timed using the system's high-resolution performance counter.")
   Else
      Console.WriteLine("Operations timed using the DateTime class.")
   End If
   
   Dim frequency As Long = Stopwatch.Frequency
   Console.WriteLine("  Timer frequency in ticks per second = {0}", frequency)
   Dim nanosecPerTick As Long = 1000000000 / frequency
   Console.WriteLine("  Timer is accurate within {0} nanoseconds", nanosecPerTick)

End Sub

설명

클래스에서 Stopwatch 사용하는 타이머는 시스템 하드웨어 및 운영 체제에 따라 달라집니다. IsHighResolutiontrue 타이머가 Stopwatch 고해상도 성능 카운터를 기반으로 하는 경우 입니다. 그렇지 않은 경우 는 IsHighResolutionfalse타이머가 시스템 타이머를 Stopwatch 기반으로 했음을 나타내는 입니다.

적용 대상

추가 정보