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
58
59
60
61
62
| #include "types.h"
|
| #include <time.h>
|
| #if defined(WIN32)
| #include <WinSock2.h>
| #include <Windows.h>
| #include <direct.h>
| #include <io.h> //C (Windows) access
| #else
| #include <sys/time.h>
| #include <stdio.h>
| #include <unistd.h>
|
| void Sleep(long mSeconds)
| {
| usleep(mSeconds * 1000);
| }
|
| #endif
|
| void mSleep(int mSecond)
| {
| #if defined(WIN32)
| Sleep(mSecond);
| #else
| usleep(mSecond * 1000);
| #endif
| }
|
|
| int64_t getTimeStamp_MilliSecond()
| {
|
| int mSecond = 0;
|
| #if defined(WIN32)
|
| SYSTEMTIME sys;
| GetLocalTime( &sys );
|
| mSecond = sys.wMilliseconds;
|
| #else
|
| struct timeval tv;
| struct timezone tz;
|
| struct tm *p;
|
| gettimeofday(&tv, &tz);
| p = localtime(&tv.tv_sec);
|
| mSecond = tv.tv_usec / 1000;
|
|
| #endif
|
| int64_t timeStamp = ((int64_t)time(NULL)) * 1000 + mSecond;
|
| return timeStamp;
| }
|
|