C++ std::chrono 计时器的使用
使用标准库
#include <chrono> int main() { auto stampBeg = std::chrono::steady_clock::now(); // do someting Sleep(2400); auto stampEnd = std::chrono::steady_clock::now(); double time_second = std::chrono::duration<double>(stampEnd - stampBeg).count(); double time_millisecond = std::chrono::duration<double, std::milli>(stampEnd - stampBeg).count(); double time_microsecond = std::chrono::duration<double, std::micro>(stampEnd - stampBeg).count(); double time_nanosecond = std::chrono::duration<double, std::nano>(stampEnd - stampBeg).count(); return 0; }