How offen could I use KeQueryPerfomanceCounter function

KeQueryPerfomanceCounter is a very useful function to measure time. But
DDK doesn’t recomend to use it oftenly. I didn’t understant what does it
mean (oftenly)? Is it normal, if I will call it every 10ms?
What does this function do?

Usually that sort of cautionary advice means the function is expensive
either in terms of CPU time or system throughput (eg, contention for
locks, I/O), or both. Whether every 10 ms is too often will depend in
part on the machine (speed of CPU and memory, number of CPUs, amount of
memory, etc). Off the top of my head (correct me), I think the default
timer resolution is 1 ms, so perhaps an interval of 10 ms is on the high
side of tolerability.


If replying by e-mail, please remove “nospam.” from the address.

James Antognini

To my knowledge, this function simply returns the 64-bit CPU cycle
counter in Pentium and later CPUs returned by the instruction RDTSC.
This isn’t an expensive operation, but RDTSC is a privelaged
instruction, and the OS may be context-switching to a supervisor level
before executing the instruction, then switching back. Perhaps someone
else can comment on the overhead of context switching under Windows.

Chuck

----- Original Message -----
From: “Akorolev”
To: “NT Developers Interest List”
Sent: Friday, October 25, 2002 12:41 AM
Subject: [ntdev] How offen could I use KeQueryPerfomanceCounter function

> KeQueryPerfomanceCounter is a very useful function to measure time.
But
> DDK doesn’t recomend to use it oftenly. I didn’t understant what does
it
> mean (oftenly)? Is it normal, if I will call it every 10ms?
> What does this function do?
>
> —
> You are currently subscribed to ntdev as: xxxxx@cbatson.com
> To unsubscribe send a blank email to %%email.unsub%%
>

Does supervisor level mean execution from Ring 0 ?
KeQueryPerfomanceCounter could return another argument -
PerformanceFrequency.
I tested work of this function on notebook PC with perfomance fluency.
When I started watching a film - PerformanceFrequency grows up, when I
stopped PerformanceFrequency falls down.
May be you know how does this function estmate this argument ? May be this
operation is critical ?

To my knowledge, this function simply returns the 64-bit CPU cycle
counter in Pentium and later CPUs returned by the instruction RDTSC.
This isn’t an expensive operation, but RDTSC is a privelaged
instruction, and the OS may be context-switching to a supervisor level
before executing the instruction, then switching back. Perhaps someone
else can comment on the overhead of context switching under Windows.

Chuck

----- Original Message -----
From: “Akorolev”
> To: “NT Developers Interest List”
> Sent: Friday, October 25, 2002 12:41 AM
> Subject: [ntdev] How offen could I use KeQueryPerfomanceCounter function
>
>
> > KeQueryPerfomanceCounter is a very useful function to measure time.
> But
> > DDK doesn’t recomend to use it oftenly. I didn’t understant what does
> it
> > mean (oftenly)? Is it normal, if I will call it every 10ms?
> > What does this function do?
> >
> > —
> > You are currently subscribed to ntdev as: xxxxx@cbatson.com
> > To unsubscribe send a blank email to %%email.unsub%%
> >