(double)(time2-time1)/CLOCKS_PER_SEC; It's not real CPU time but actual execution time. Actual CPU time calculation is way too complicated and platform/OS dependent.