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 システム ハードウェアとオペレーティング システムによって異なります。 IsHighResolution は、 true タイマーが Stopwatch 高解像度のパフォーマンス カウンターに基づいている場合です。 それ以外の場合、 IsHighResolutionfalseで、タイマーがシステム タイマーに基づいていることを Stopwatch 示します。

適用対象

こちらもご覧ください