A customer was using the
function for high-resolution
profiling of performance-sensitive code,
but found that its accuracy is rather poor.
They were hoping there would be something more
along the lines of a
that reported only CPU time consumed by a particular thread,
rather than by the system in general.
Fortunately, there is.
gives you the CPU cycles consumed by a particular thread.
This includes time spent both in user mode and in kernel mode.
Note, however, that these values are reported directly from the CPU using mechanisms like RDTSC or the performance monitor control register. This means that the actual results are at the mercy of whatever the CPU manufacturer decides the CPU cycle counter means. Maybe they correspond to wall clock time; maybe they don't.