Previous Next

KeQueryPerformanceCounter

The KeQueryPerformanceCounter routine provides the finest grained running count available in the system.

LARGE_INTEGER 
  KeQueryPerformanceCounter(
    OUT PLARGE_INTEGER  PerformanceFrequency  OPTIONAL
    );

Parameters

PerformanceFrequency
Optionally specifies a pointer to a variable that receives the performance counter frequency.

Headers

Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.

Return Value

KeQueryPerformanceCounter returns the performance counter value in units of ticks.

Comments

KeQueryPerformanceCounter always returns a 64-bit integer representing the current number of ticks. Accumulating the count begins when the system is booted.

The resolution of the timer used to accumulate the current count can be obtained by specifying a pointer value for PerformanceFrequency. The value returned is the number of ticks per second.

KeQueryPerformanceCounter is intended for time-stamping packets or for computing performance and capacity measurements. It is not intended for measuring elapsed time, for computing stalls or waits, or for iterations.

Use this routine as infrequently as possible. Depending on the platform, KeQueryPerformanceCounter can disable system-wide interrupts for a minimal interval. Consequently, calling this routine frequently, as in an iteration, defeats its purpose of returning very fine-grained, running time-stamp information. Calling this routine too frequently can degrade I/O performance for the calling driver and for the system as a whole.

Callers of KeQueryPerformanceCounter can be running at any IRQL.

See Also

KeQueryInterruptTime, KeQuerySystemTime, KeQueryTickCount, KeQueryTimeIncrement