[plug] Timer library/functions
Christian
christian at amnet.net.au
Fri Apr 7 13:46:48 WST 2000
Hi all,
Does anyone know of a C function(s) or library that allow the programmer
to record the time that's elapsed (to a reasonable resolution, i.e., *at
least* milliseconds; preferably microseconds) between two subsequent
system calls? There seem to be lots of functions and libraries to set a
timer which goes off after the specified time but nothing which actually
allows the time between two intra-program events to be measured.
My current idea is to use setitimer() and set a signal handler for
SIGALRM which increments a counter. Since the resolution here is
microseconds then I can set the interval to be, say, 10 microseconds.
Thus the counter will indicate the length of time between when the
interval was set and when it was stopped. My main concern here is that
the overhead of signal delivery and handler execution will badly skew
the timing -- does anyone have any ideas on how bad this will be?
Specifically, will the skew affect precision or just accuracy? Accuracy
in this case is relatively unimportant but precision is essential.
Regards,
Christian.
More information about the plug
mailing list