Stopwatch.Frequency 필드

정의

초당 틱 수로 나타낸 타이머의 빈도를 가져옵니다. 이 필드는 읽기 전용입니다.

public: static initonly long Frequency;
public static readonly long Frequency;
 staticval mutable Frequency : int64
Public Shared ReadOnly Frequency As Long 

필드 값

예제

다음 예제에서는 타이머의 빈도 및 해상도를 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

설명

타이머 빈도는 타이머 정밀도 및 해상도를 나타냅니다. 예를 들어 초당 2백만 틱의 타이머 주파수는 틱당 500나노초의 타이머 해상도와 같습니다. 즉, 1초가 10억 나노초와 같기 때문에 초당 200만 틱의 타이머 주파수는 10억 나노초당 2백만 개의 틱에 해당하며, 이는 500나노초당 1틱으로 더 간소화될 수 있습니다.

값은 Frequency 기본 타이밍 메커니즘의 해결에 따라 달라집니다. 설치된 하드웨어 및 운영 체제가 고해상도 성능 카운터를 지원하는 경우 값은 Frequency 해당 카운터의 빈도를 반영합니다. 그렇지 않으면 값은 Frequency 시스템 타이머 빈도를 기반으로 합니다.

빈도는 Stopwatch 설치된 하드웨어 및 운영 체제 Frequency 에 따라 달라지므로 시스템이 실행되는 동안 값은 일정하게 유지됩니다.

적용 대상

추가 정보