std.perf
Platform-independent performance measurement and timing classes. PerformanceCounter is the main platform-independent timer class provided, covering the most typical use case, measuring elapsed wall-clock time. The module also provides several Windows-specific timers that can be useful in specialized situations. Synopsis:alias PerformanceCounter.interval_t interval_t; auto timer = new PerformanceCounter; timer.start(); // do computation timer.stop(); interval_t elapsedMsec = timer.milliseconds; writefln("Time elapsed: %s msec", elapsedMsec);In particular note that stop() must be called before querying the elapsed time. These classes were ported to D from the STLSoft C++ libraries, which were documented in the article " Win32 Performance Measurement Options", May 2003 issue of Windows Develper Network. Author:
Matthew Wilson Source:
std/perf.d
- A performance counter that uses the most accurate measurement APIs available on the host machine
On Linux, the implementation uses gettimeofday().
For Windows, QueryPerformanceCounter() is used if available,
GetTickCount() otherwise.
- The type of the interval measurement (generally a 64-bit signed integer)
- Starts measurement Begins a measurement period
- Ends measurement Marks the end of a measurement period. This must be called before querying the elapsed time with period_count, seconds, milliseconds, or microseconds. The stop() method may be called multiple times without an intervening start(). Elapsed time is always measured from most recent start() to the most recent stop().
- The elapsed count in the measurement period This represents the extent, in machine-specific increments, of the measurement period
- The number of whole seconds in the measurement period This represents the extent, in whole seconds, of the measurement period
- The number of whole milliseconds in the measurement period This represents the extent, in whole milliseconds, of the measurement period
- The number of whole microseconds in the measurement period This represents the extent, in whole microseconds, of the measurement period
- A low-cost, low-resolution performance counter
This class provides low-resolution, but low-latency, performance monitoring.
This class is available only on Windows, but
is guaranteed to be meaningful on all Windows operating systems.
- The interval type The type of the interval measurement (generally a 64-bit signed integer)
- Starts measurement Begins a measurement period
- Ends measurement Marks the end of a measurement period. This must be called before querying the elapsed time with period_count, seconds, milliseconds, or microseconds. The stop() method may be called multiple times without an intervening start(). Elapsed time is always measured from most recent start() to the most recent stop().
- The elapsed count in the measurement period This represents the extent, in machine-specific increments, of the measurement period
- The number of whole seconds in the measurement period This represents the extent, in whole seconds, of the measurement period
- The number of whole milliseconds in the measurement period This represents the extent, in whole milliseconds, of the measurement period
- The number of whole microseconds in the measurement period This represents the extent, in whole microseconds, of the measurement period
- A performance counter that provides thread-specific performance timings
This class uses the operating system's performance monitoring facilities to provide timing
information pertaining to the calling thread only, irrespective of the activities of other
threads on the system. This class does not provide meaningful timing information on operating
systems that do not provide thread-specific monitoring.
This class is available only on Windows.
- The interval type The type of the interval measurement (generally a 64-bit signed integer)
- this();
- Constructor Creates an instance of the class, and caches the thread token so that measurements will be taken with respect to the thread in which the class was created.
- Starts measurement Begins a measurement period
- Ends measurement Marks the end of a measurement period. This must be called before querying the elapsed time with period_count, seconds, milliseconds, or microseconds. The stop() method may be called multiple times without an intervening start(). Elapsed time is always measured from most recent start() to the most recent stop().
- The elapsed count in the measurement period for kernel mode activity This represents the extent, in machine-specific increments, of the measurement period for kernel mode activity
- The number of whole seconds in the measurement period for kernel mode activity This represents the extent, in whole seconds, of the measurement period for kernel mode activity
- The number of whole milliseconds in the measurement period for kernel mode activity This represents the extent, in whole milliseconds, of the measurement period for kernel mode activity
- The number of whole microseconds in the measurement period for kernel mode activity This represents the extent, in whole microseconds, of the measurement period for kernel mode activity
- The elapsed count in the measurement period for user mode activity This represents the extent, in machine-specific increments, of the measurement period for user mode activity
- The number of whole seconds in the measurement period for user mode activity This represents the extent, in whole seconds, of the measurement period for user mode activity
- The number of whole milliseconds in the measurement period for user mode activity This represents the extent, in whole milliseconds, of the measurement period for user mode activity
- The number of whole microseconds in the measurement period for user mode activity This represents the extent, in whole microseconds, of the measurement period for user mode activity
- The elapsed count in the measurement period This represents the extent, in machine-specific increments, of the measurement period
- The number of whole seconds in the measurement period This represents the extent, in whole seconds, of the measurement period
- The number of whole milliseconds in the measurement period This represents the extent, in whole milliseconds, of the measurement period
- The number of whole microseconds in the measurement period This represents the extent, in whole microseconds, of the measurement period
- A performance counter that provides process-specific performance timings
This class uses the operating system's performance monitoring facilities to provide timing
information pertaining to the calling process only, irrespective of the activities of other
processes on the system. This class does not provide meaningful timing information on operating
systems that do not provide process-specific monitoring.
This class is available only on Windows.
- The interval type The type of the interval measurement (generally a 64-bit signed integer)
- Starts measurement Begins a measurement period
- Ends measurement Marks the end of a measurement period. This must be called before querying the elapsed time with period_count, seconds, milliseconds, or microseconds. The stop() method may be called multiple times without an intervening start(). Elapsed time is always measured from most recent start() to the most recent stop().
- The elapsed count in the measurement period for kernel mode activity This represents the extent, in machine-specific increments, of the measurement period for kernel mode activity
- The number of whole seconds in the measurement period for kernel mode activity This represents the extent, in whole seconds, of the measurement period for kernel mode activity
- The number of whole milliseconds in the measurement period for kernel mode activity This represents the extent, in whole milliseconds, of the measurement period for kernel mode activity
- The number of whole microseconds in the measurement period for kernel mode activity This represents the extent, in whole microseconds, of the measurement period for kernel mode activity
- The elapsed count in the measurement period for user mode activity This represents the extent, in machine-specific increments, of the measurement period for user mode activity
- The number of whole seconds in the measurement period for user mode activity This represents the extent, in whole seconds, of the measurement period for user mode activity
- The number of whole milliseconds in the measurement period for user mode activity This represents the extent, in whole milliseconds, of the measurement period for user mode activity
- The number of whole microseconds in the measurement period for user mode activity This represents the extent, in whole microseconds, of the measurement period for user mode activity
- The elapsed count in the measurement period This represents the extent, in machine-specific increments, of the measurement period
- The number of whole seconds in the measurement period This represents the extent, in whole seconds, of the measurement period
- The number of whole milliseconds in the measurement period This represents the extent, in whole milliseconds, of the measurement period
- The number of whole microseconds in the measurement period This represents the extent, in whole microseconds, of the measurement period