-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime_cnt.cpp
57 lines (49 loc) · 956 Bytes
/
time_cnt.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include "time_cnt.hpp"
namespace time_cnt
{
/**
* @author: fhn
* @date: 4/20
* @version: 1.0
* @description: three modes of sleeping of different time span,
this is the substitution for sleep() in "Windows.h", in order to guaratee the protability between windows, linux and mac.
sleep1: INT_MAX/10
*/
void Sleep1()
{
int i = 0, bound = INT_MAX/10;
while (++i <= bound);
}
//sleep2: INT_MAX/15
void Sleep2()
{
int i = 0, bound = INT_MAX/15;
while (++i <= bound);
}
//sleep3: INT_MAX/27
void Sleep3()
{
int i = 0, bound = INT_MAX/27;
while (++i <= bound);
}
void Sleep4()
{
int i = 0, bound = INT_MAX/80;
while (++i <= bound);
}
void Sleep5()
{
int i = 0, bound = INT_MAX/50;
while(++i <= bound);
}
clock_t s, e;
void start()
{
s = clock();
}
void end()
{
e = clock();
std::cout << "(" << (double)(e-s) / CLOCKS_PER_SEC << " sec)" << std::endl;
}
}//namespace time