C function execution time measurement under UNIX
Christophe Wolfhugel
wolf at grasp2.univ-lyon1.fr
Sat Feb 2 04:59:48 AEST 1991
In his message, Toneluh [Andy] <yang at cs.umn.edu> said:
|I'm looking for a way to measure the execution time of a function (note: not a
|process) which is called in a C program executing under UNIX. I have tried
|putting setitimer() before the function call & getitimer() after the call, but
|the returned value is zero. If you have encountered this problem before,
|please mail me your method or any possibile solution you could think of. If
|there's enough interest, I will post a summary. Thanks in advance.
Take a look at times(2)
#include <sys/types.h>
#include <sys/times.h>
...
struct tms buffer,buffer2; To get the amount of type elapsed in
... the function, just differentiate the
times(&buffer); fields between buffer2 and buffer. The
functionToMeasure(); unit is in HZth of seconds (defined I
times(&buffer2); don't remembet where).
...
--
Christophe Wolfhugel (on irc: loto) | Email: wolf at grasp1.univ-lyon1.fr
INSA Lyon - Departement Informatique | IRC'adm for node grasp1.univ-lyon1.fr
69621 Villeurbanne Cedex, France | Fax: (+33) 88 68 11 84
Disclaimer: these are my own opinions, not my employer's.
More information about the Comp.unix.questions
mailing list