Jay Witherspoon <email@example.com> wrote:
I was looking for a simple way to measure time spent in various routines of
my program (multiple processes) and was thinking about using slogf and
outputing a timestamp and location at key points. Since I am running under
multiple processes, I was looking for a timestamp in the millisecond range
that would be common accross processes. I understand there is a single
counter per cpu (and we only have one). However, then I handle if it rolls
over (maybe multiple times?) between snapshots.
Is there a better single time routine that has better than second resolution
to use for the time stamp?
clock_gettime() will give you 32 bit seconds, 32 bit nanoseconds since
last second. Resolution is your ticksize (normally about 1ms).
ClockCycles() will give 64-bit value of free running counter. Resolution
(On x86, for example, ClockCycles() is based on the pentium and above
rtdsc opcode, which updates at the core frequency, that is, on a
1GHz machine, it would have a resolution of 1ns.)
QNX Training Services
Please followup in this newsgroup if you have further questions.