Re: what exactly does CPU_TIME measure?
- From: Janne Blomqvist <foo@xxxxxxxxxxx>
- Date: Thu, 26 Apr 2007 23:15:54 +0300 (EEST)
In article <2tydnZXVes5fdq3bnZ2dnUVZ_oytnZ2d@xxxxxxxxxxx>, glen herrmannsfeldt wrote:
mecej4 wrote:
(snip)
Some recent processors incorporate frequency changing as part of their
power saving strategy, which makes it harder to use a hardware register
to keep track of time.
If, in fact, RDTSC gives the quantity \int_0^T \f dt, one has to
differentiate the RDTSC readings and then evaluate \int_0^T dt!
Yes, but if you consider the goal of minimizing the number of
clock cycles then rdtsc makes more sense. Or, to put it
another way, not all CPU seconds are equal (on a variable
speed CPU) but clock cycles are.
On the other hand, rdtsc measure wall time, not CPU time.
No, it measures the cpu tick count (which is why the CPU changing
frequency is a problem for timing). Secondly each CPU has its own TSC,
which is not synchronized with the TSC:s of other CPU:s, so if your
app happens to switch to another CPU on a multiprocessor -> oops.
For these reasons, RDTSC is pretty useless these days. Which is a bit
of a shame, since as such it's the most accurate and lowest overhead
timer available.
See e.g.
http://www.ussg.iu.edu/hypermail/linux/kernel/0505.1/1463.html
http://en.wikipedia.org/wiki/RDTSC
If you time small enough sections of code you will rarely be
interrupted. Small sections are difficult to time with a coarse
resolution clock.
Fancier profilers these days seem to use hw counters and sampling
(e.g. oprofile), so you can get accurate timing even for small
sections, provided the loop count is high enough.
--
Janne Blomqvist
.
- Follow-Ups:
- Re: what exactly does CPU_TIME measure?
- From: glen herrmannsfeldt
- Re: what exactly does CPU_TIME measure?
- References:
- what exactly does CPU_TIME measure?
- From: Bart Vandewoestyne
- Re: what exactly does CPU_TIME measure?
- From: Daniel Franke
- Re: what exactly does CPU_TIME measure?
- From: Tim Prince
- Re: what exactly does CPU_TIME measure?
- From: mecej4
- Re: what exactly does CPU_TIME measure?
- From: glen herrmannsfeldt
- what exactly does CPU_TIME measure?
- Prev by Date: Re: what exactly does CPU_TIME measure?
- Next by Date: Re: MATMUL implementations
- Previous by thread: Re: what exactly does CPU_TIME measure?
- Next by thread: Re: what exactly does CPU_TIME measure?
- Index(es):
Relevant Pages
|