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;
}

  

posted @ 2023-07-07 10:44  路边的十元钱硬币  阅读(193)  评论(0编辑  收藏  举报