Hi Axel On Saturday 16 April 2005 08:56 am, Axel Dörfler wrote: > I would guess it's pretty low overhead on most platforms, at least it > would be worth a try. On the platforms I've tested so far, it does appear that the resolution of gettimeofday() should be sufficient and the overhead is minimal. I've attached some preliminary results of the platforms I've tested so far in case anybody's interested. Don't read too much into these numbers. > I'm pretty sure it's not tied to the CPU frequency, so it should be a > good candidate. Yes. I remember reading somewhere that it's derived from the front-side bus speed. Must try and find some official documentation on this. > It's measured by BeOS on startup; BeOS depends its timing on the TSC > itself (that's why it has numerous problems on CPUs that change their > frequency). So it's as exact as BeOS' timing. Ah. Interesting. > There is probably just not that much choice in userland. Not on Linux. Other ('proper') Unices seem to have a lot more functionality in this regard. E.g. get_hrtime() on Solaris. Cheers, Rich
PowerMac 9500 333 MHz PPC750 - Mac OS 10.2 ------------------------------------------ Testing gettimeofday() ---------------------- Testing granularity... Estimated granularity : 14 usecs Testing overhead Doing 10000000 iterations... start time: 1113712622 secs 111152 usecs end time: 1113712668 secs 672116 usecs total time: 46 secs 560964 usecs time per call: 4.656096 usecs PowerMac 9500 333 MHz PPC750 - Linux 2.6.8.1 -------------------------------------------- Testing gettimeofday() ---------------------- Testing granularity... Estimated granularity : 3 usecs Testing overhead Doing 10000000 iterations... start time: 1113731911 secs 147279 usecs end time: 1113731918 secs 699845 usecs total time: 7 secs 552566 usecs time per call: 0.755257 usecs Starmax 3000 233 MHz PPC750 - Linux 2.4.21 ------------------------------------------ Testing gettimeofday() ---------------------- Testing granularity... Estimated granularity : 3 usecs Testing overhead Doing 10000000 iterations... start time: 1113712725 secs 358999 usecs end time: 1113712737 secs 785402 usecs total time: 12 secs 426403 usecs time per call: 1.242640 usecs 1800 MHz Athlon XP 2200+ - Linux 2.6.10 --------------------------------------- Testing gettimeofday() ---------------------- Testing granularity... Estimated granularity : 2 usecs Testing overhead Doing 10000000 iterations... start time: 1113713402 secs 376501 usecs end time: 1113713420 secs 607344 usecs total time: 18 secs 230843 usecs time per call: 1.823084 usecs AmigaOne 800MHz PPC7455 - AmigaOS 4.0 beta ------------------------------------------ Testing gettimeofday() ---------------------- Testing granularity... Estimated granularity : 3 usecs Testing overhead Doing 10000000 iterations... start time: 1113634421 secs 230755 usecs end time: 1113634427 secs 674649 usecs total time: 6 secs 443894 usecs time per call: 0.644389 usecs