1、定义一个测试时间函数
类似于windows下Get Tick Count() 这种函数,时间是不准的 使用std::chrono::system_clock来获取时间
class TicToc
{
public:
TicToc()
{
tic();
}
void tic()
{
start = std::chrono::system_clock::now();
}
double toc()
{
end = std::chrono::system_clock::now();
std::chrono::duration elapsed_seconds = end - start;
return elapsed_seconds.count() * 1000;
}
private:
std::chrono::time_point start, end;
};
输出为毫秒
2、定义测试函数int result_future()
{
int i=0,ret = 0;
std::this_thread::sleep_for(std::chrono::seconds(2));
return ret + 1;
}
int result_add(int x, int y)
{
return x + y;
}
void print_point(int x)
{
std::cout
关注
打赏