使用标准库
#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; }
标签:std,chrono,double,C++,stampBeg,stampEnd,duration From: https://www.cnblogs.com/alexYuin/p/17534221.html