Stopwatch.Frequency Alan

Tanım

Saniyedeki değer sayısı olarak zamanlayıcının sıklığını alır. Bu alan salt okunur durumdadır.

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

Alan Değeri

Örnekler

Aşağıdaki örnek zamanlayıcının Stopwatch sıklığını ve çözünürlüğünü görüntüler. Bu kod örneği, sınıfı için Stopwatch sağlanan daha büyük bir örneğin parçasıdır.

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

Açıklamalar

Zamanlayıcı sıklığı zamanlayıcı duyarlığını ve çözünürlüğünü gösterir. Örneğin, saniyede 2 milyon değer çizgisi olan bir zamanlayıcı sıklığı, tick başına 500 nanosaniyelik bir zamanlayıcı çözünürlüğüne eşittir. Başka bir deyişle, bir saniye 1 milyar nanosaniyeye eşit olduğundan, saniyede 2 milyon ticks zamanlayıcı sıklığı, 1 milyar nanosaniye başına 2 milyon değere eşdeğerdir ve bu da 500 nanosaniyede 1 değere daha da basitleştirilebilir.

Değer, Frequency temel zamanlama mekanizmasının çözünürlüğüne bağlıdır. Yüklü donanım ve işletim sistemi yüksek çözünürlüklü bir performans sayacını destekliyorsa, Frequency değer bu sayacın sıklığını yansıtır. Aksi takdirde, Frequency değer sistem zamanlayıcı sıklığını temel alır.

Stopwatch Sıklık yüklü donanıma ve işletim sistemine bağlı olduğundan, Frequency sistem çalışırken değer sabit kalır.

Şunlara uygulanır

Ayrıca bkz.