How to determine the time taken for any function?

Hello, i have my project code, and i need to find out the time for the functions used in it, how do i do that?
for example:
my function is
GSM();
and i check the time before calling this function and right after it ends its execution?
if its for any specific function then you can use clock().
1
2
3
4
double start_time = clock();

double end_time = clock();
double elapsed_time = (end_time - start_time) / CLOCKS_PER_SEC;

if you want it for each function it will be better if you use any code profiling tool, like gprof(linux), on windows i think boundschecks can do the profiling.
Thanks, that was useful.

But still it shows a zero "0". my code runs in less then a sec. how can i change the output to less then a second?
Topic archived. No new replies allowed.