MCPcopy Create free account
hub / github.com/catboost/catboost / GetWallTime

Function GetWallTime

library/cpp/chromium_trace/gettime.cpp:25–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23 }
24
25 TInstant GetWallTime() {
26#ifdef _win_
27 LARGE_INTEGER counter;
28 LARGE_INTEGER frequency;
29 if (QueryPerformanceCounter(&counter) && QueryPerformanceFrequency(&frequency)) {
30 return TInstant::MicroSeconds(counter.QuadPart * 1'000'000 / frequency.QuadPart);
31 }
32 return {};
33#else
34 // With "complete" events, trace viewer relies only on timestamps to
35 // restore sequential ordering of events. In case of two events too
36 // close in time, it fails to disambiguate between them. It is
37 // acceptable to adjust time a bit, just to get a unique timestamp in
38 // each call.
39 // Tracing is not pretty much useful at sub-microsecond scale anyway.
40 static thread_local ui64 LastTimeStamp = 0;
41 LastTimeStamp = Max(LastTimeStamp + 1, MicroSeconds());
42 return TInstant::MicroSeconds(LastTimeStamp);
43#endif
44 }
45}

Callers 1

NowMethod · 0.85

Calls 2

MicroSecondsFunction · 0.85
MaxFunction · 0.50

Tested by

no test coverage detected