Timing algorithm: clock() vs time() in C++

后端 未结 5 849
失恋的感觉
失恋的感觉 2020-12-22 23:08

For timing an algorithm (approximately in ms), which of these two approaches is better:

clock_t start = clock();
algorithm();
clock_t end = clock();
double t         


        
5条回答
  •  醉酒成梦
    2020-12-22 23:24

    is the best. Visual Studio 2013 provides this feature. Personally, I have tried all the methods mentioned above. I strongly recommend you use the library. It can track the wall time and at the same time have a good resolution (much less than a second).

提交回复
热议问题