Hi ,I need to figure out the running time of a program ,is there any build in function in c(like System.currentTimeMillis() in JAVA),or I have to write one
Thanks
Hi ,I need to figure out the running time of a program ,is there any build in function in c(like System.currentTimeMillis() in JAVA),or I have to write one
Thanks
Last edited by lio; 01-21-2011 at 04:56 AM.
There is no inbuilt function apart from the time library to use. If you want to profile your code there are library avaliable out there. Check you compiler documenation or if your gcc you could use gprof.
ssharish
Life is like riding a bicycle. To keep your balance you must keep moving - Einstein
I think this may help you out. This gives the the approximate time (more than the observed running time by "time" command in linux).
Thanks and Best Regards,Code:#include <stdio.h> #include <time.h> int main() { int time1, time2; time1 = clock(); //Initial Observation /* Your code */ time2 = clock(); //Final observation printf ("Time Elapsed = %f\n", (float)(time2 - time1) / (float)CLOCKS_PER_SEC); return 0; }
Aakash Johari