c++11 耗时计算 微秒级

class TimeCasterMicro final
{
public:
	TimeCasterMicro()
		:record{std::chrono::system_clock::now()}
	{
		std::cout << "Start!\n";
	}
	
	~TimeCasterMicro()
	{
		auto now = std::chrono::system_clock::now();
		auto time_span = std::chrono::duration_cast<std::chrono::microseconds>(now - record);
		std::cout << "Spend Time = "
				  << time_span.count()
				  << "us"
				  << std::endl;
	}

public:
	std::chrono::system_clock::time_point record;
};
//  使用:

auto time = new TimeCasterMicro;
delete time;

{
	TimeCasterMicro time;
}

{
	std::unique_ptr<TimeCasterMicro> time(new TimeCasterMicro);
}
上一篇:MySQL Fabric部署


下一篇:如何有效的管理时间和任务?Chrono Plus 快速管理日程!