forked from DragonFive/cpp11
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpp11_18_Chrono.cpp
More file actions
37 lines (32 loc) · 919 Bytes
/
cpp11_18_Chrono.cpp
File metadata and controls
37 lines (32 loc) · 919 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/************************************************************************
* 代码标签 : chrono中的duration和tine_point结构;
* 功能描述 :
* 类 名 称 :
* 版 本 号 : v1.0
* 说 明 :
* 作 者 : dragonfive
* 创建时间 :
* 更新时间 :
************************************************************************
* Copyright @dragonfive 2016 . All rights reserved.
************************************************************************/
#include <chrono>
#include <iostream>
using namespace std;
using namespace chrono;
int main()
{
auto start = system_clock::now();//这个是chrono的time_point类型;
// do something...
int sum=0;
for(int i=0;i<10000000;i++)
{
sum+=i;
}
auto end = system_clock::now();
auto duration = duration_cast<microseconds>(end - start);
cout << "花费了"
<< duration.count()
<< "微秒" << endl;
return 0;
}