Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!ames!elroy.jpl.nasa.gov!sdd.hp.com!news.cs.indiana.edu!news.nd.edu!mentor.cc.purdue.edu!purdue!haven!adm!news From: wolf@grasp2.univ-lyon1.fr (Christophe Wolfhugel) Newsgroups: comp.unix.questions Subject: Re: C function execution time measurement under UNIX Message-ID: <25797@adm.brl.mil> Date: 1 Feb 91 17:59:48 GMT Sender: news@adm.brl.mil Lines: 26 In his message, Toneluh [Andy] 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 #include ... 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@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.