YDLIDAR X2 SDK  V1.4.1
timer.h
1 #pragma once
2 #include "v8stdint.h"
3 #include <assert.h>
4 #include <time.h>
5 #include <inttypes.h>
6 
7 
8 
9 #define BEGIN_STATIC_CODE( _blockname_ ) \
10  static class _static_code_##_blockname_ { \
11  public: \
12  _static_code_##_blockname_ ()
13 
14 
15 #define END_STATIC_CODE( _blockname_ ) \
16  } _instance_##_blockname_;
17 
18 
19 #if defined(_WIN32)
20 #include <windows.h>
21 #define delay(x) ::Sleep(x)
22 #else
23 #include <sys/time.h>
24 #include <unistd.h>
25 
26 static inline void delay(uint32_t ms) {
27  while (ms >= 1000) {
28  usleep(1000 * 1000);
29  ms -= 1000;
30  };
31 
32  if (ms != 0) {
33  usleep(ms * 1000);
34  }
35 }
36 #endif
37 
38 
39 namespace impl {
40 
41 #if defined(_WIN32)
42 void HPtimer_reset();
43 #endif
44 uint32_t getHDTimer();
45 uint64_t getCurrentTime();
46 }
47 
48 
49 #define getms() impl::getHDTimer()
50 #define getTime() impl::getCurrentTime()
Definition: timer.h:39