Commit 01391ec9 authored by aligungr's avatar aligungr

Performance improvements

parent 9ca343a5
......@@ -148,11 +148,20 @@ int utils::NextId()
int64_t utils::CurrentTimeMillis()
{
auto time = std::chrono::system_clock::now();
auto sinceEpoch = time.time_since_epoch();
auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(sinceEpoch);
int64_t now = millis.count();
return now;
return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
.count();
}
int64_t utils::CurrentTimeMicros()
{
return std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::system_clock::now().time_since_epoch())
.count();
}
int64_t utils::CurrentTimeNanos()
{
return std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::system_clock::now().time_since_epoch())
.count();
}
TimeStamp utils::CurrentTimeStamp()
......
......@@ -28,6 +28,8 @@ int GetIpVersion(const std::string &address);
OctetString IpToOctetString(const std::string &address);
std::string OctetStringToIp(const OctetString &address);
int64_t CurrentTimeMillis();
int64_t CurrentTimeMicros();
int64_t CurrentTimeNanos();
TimeStamp CurrentTimeStamp();
int NextId();
int ParseInt(const std::string &str);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment