DIGIT-ARC read-only archive · snapshot: July 23, 2026

Finding function run time in C/C++

3 posts · originally from https://geek.digit.in/community/threads/finding-function-run-time-in-c-c.107700/

T
ThinkFree Original post #1
Jan 31, 2009 at 5:53 PM
How can I find the time taken by a function during function executiong? time_t and clock function give time in mili second range, but I want time in micro/nano second range as using these time comes out to be 0. The only solution I could find was making a loop run a large number of time and dividing total time by that number, which I want to avoid. Can anyone help?
dheeraj_kumar
Jan 31, 2009 at 6:41 PM
Read:

*www.devx.com/cplus/Article/35375/1954

if you are using visual c++,

*www.codeproject.com/KB/system/timers_intro.aspx
T
Feb 1, 2009 at 2:34 PM
Thanks for the reply
sys/time.h solved the problem.