I'm using time.h in C++ to measure the timing of a function.
clock_t t = clock();
someFunction();
printf("
Time taken: %.4fs
", (float)(clock() - t)/CLOCKS_PER_SEC);
however, I'm always getting the time taken as 0.0000. clock() and t when printed separately, have the same value. I would like to know if there is way to measure the time precisely (maybe in the order of nanoseconds) in C++ . I'm using VS2010.
See Question&Answers more detail:os