This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

using get_cycles() to get the real elapsed time


Hi,
I took a look at the runtime/time.c and found it uses get_cycles()/freq to get the elapsed time:


   ...
   delta = get_cycles() - last;
   do_div(delta, freq);
   ...
   return (USEC_PER_SEC * (int64_t)base.tv_sec) + base.tv_usec + delta;

But AFAIK, some architectures will increase Time Base register(i.e TSC) with a fixed ratio of cpu freq. On x86, this = cpu freq. and on Power5, Time Base driven at 1/8 the processor clock frequency. I even remembered that on some old PowerPC(4xx, 7xx) the Time Base is driven by the bus clock(33Mhz)

So we need deal with different Arches to get the elapsed time by using get_cycles()

BTW, get_cycles() will return 32-bit value for some architectures e.g ppc32, although the major architectures such as ppc64, x86, x86_64 will all return a 64-bit value. Should we care about those architectures whose get_cycles() returns 32-bit value?

Thanks.

- Guanglei


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]