#include #include double getCPU(void) { return (double) clock()/CLOCKS_PER_SEC; /* convert to seconds */ } void MyExpensiveFunction(void) { double g; int i; for (i=0; i<10000000; i++) g *= 2; } int main(void) { double t0,dt; t0 = getCPU(); /* get initial value */ MyExpensiveFunction(); dt = getCPU() - t0; /* difference to get execution time */ (void) printf("Execution time: %g sec\n",dt); return 0; }