Skip to content

Commit c1c5790

Browse files
committed
remove boost
1 parent d0f33b8 commit c1c5790

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

CScopedTimer.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22

33

44
std::map<std::string, int> CScopedTimer::taskIDs;
5-
std::map<std::string, unsigned int> CScopedTimer::curTime;
6-
std::map<std::string, unsigned int> CScopedTimer::prevTime;
5+
std::map<std::string, std::int64_t> CScopedTimer::curTime;
6+
std::map<std::string, std::int64_t> CScopedTimer::prevTime;
77
std::vector<std::string> CScopedTimer::tasks;
88

9+
static inline std::int64_t GetTimeNSec() {
10+
return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::high_resolution_clock::now().time_since_epoch()).count();
11+
}
12+
913
CScopedTimer::CScopedTimer(const std::string& s, IAICallback *_cb): cb(_cb), task(s) {
1014
initialized = true;
1115

@@ -21,11 +25,11 @@ CScopedTimer::CScopedTimer(const std::string& s, IAICallback *_cb): cb(_cb), tas
2125
prevTime[task] = 0;
2226
}
2327

24-
t1 = GetEngineRuntimeMSec();
28+
t1 = GetTimeNSec();
2529
}
2630

2731
CScopedTimer::~CScopedTimer() {
28-
t2 = GetEngineRuntimeMSec();
32+
t2 = GetTimeNSec();
2933

3034
if (!initialized)
3135
return;

CScopedTimer.h

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,13 @@
55
#include <map>
66
#include <vector>
77
#include <algorithm>
8-
9-
#include "boost/thread.hpp"
8+
#include <cinttypes>
9+
#include <chrono>
1010

1111
#include "headers/Defines.h"
1212
#include "headers/HAIInterface.h"
1313
#include "headers/HEngine.h"
1414

15-
#if (BOOST_VERSION >= 105000) // boost 1.50 renamed TIME_UTC to TIME_UTC_
16-
#define boost_TIME_UTC_override boost::TIME_UTC_
17-
#else
18-
#define boost_TIME_UTC_override boost::TIME_UTC
19-
#endif
2015

2116
#define PROFILE(x) CScopedTimer t(std::string(#x), ai->cb);
2217

@@ -40,21 +35,14 @@ class CScopedTimer {
4035
CScopedTimer(const std::string& s, IAICallback *_cb);
4136
~CScopedTimer();
4237

43-
static unsigned int GetEngineRuntimeMSec() {
44-
boost::xtime t;
45-
boost::xtime_get(&t, boost_TIME_UTC_override);
46-
const unsigned int milliSeconds = t.sec * 1000 + (t.nsec / 1000000);
47-
return milliSeconds;
48-
}
49-
5038
private:
5139
static std::vector<std::string> tasks;
5240
static std::map<std::string, int> taskIDs;
53-
static std::map<std::string, unsigned int> curTime, prevTime;
41+
static std::map<std::string, std::int64_t> curTime, prevTime;
5442

5543
IAICallback *cb;
5644
bool initialized;
57-
unsigned int t1, t2;
45+
std::int64_t t1, t2;
5846
const std::string task;
5947
};
6048

0 commit comments

Comments
 (0)