Calculate program execute time / time elapsed in C
Here i shared a simple method to calculate program execute time or time elapsed in C
/*calculate program execute time */
#include
#include
int main(int argc, char *argv[]) {
time_t start, stop;
clock_t ticks; long count;
time(&start);
// Do stuff
int i=0;
while(i<50000)
{
printf("Work work %d\n", i);
i++;
ticks = clock();
}
time(&stop);
printf("Used %0.2f seconds of CPU time. \n", (double)ticks/CLOCKS_PER_SEC);
printf("Finished in about %.0f seconds. \n", difftime(stop, start));
return 0;
}
helped me so much
Thanks.
hi sir.
what is answer this qustion:
calculating order (an^2+b+c)
Thanks but
please explain that parameters in program
hello sir,
my name is devi from india. i cant understand the concept behind it.
can u please explain me the concept?
thanks a lot. 😀
nice xD, (in romanian: fac laba acuma :X:X)
i want elapsed time with milliseconds in c++ or c.
example :
Start time = 01hr:45min:20sec.500ms
End time = 01hr:45min:20sec.1500ms
(1500ms-500ms =1000ms=1sec)
elapsed time = 0hr:0min:1sec.0ms
Please help