precise time measurement
问题 I'm using time.h in C++ to measure the timing of a function. clock_t t = clock(); someFunction(); printf("\nTime taken: %.4fs\n", (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. 回答1: I usually use the QueryPerformanceCounter function. example: LARGE_INTEGER