在Cpp for Linux上,我需要一个最简单的计时器来完成我的项目
两种方法就足够了:
Timer t1;
t1.start();
....
t1.gettime()
如果我包含一些头文件并有一个计时器,那就太好了。
由于c++11,您可以使用std::chrono来获取定时:
- https://en.cppreference.com/w/cpp/chrono
- https://www.techiedelight.com/measure-elapsed-time-program-chrono-library/
如果由于某种原因无法使用std::chrono,可以使用linux的clock_gettime(2(