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?