MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / orwl_gettime

Function orwl_gettime

src/core/impl/utils/timer.cpp:44–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42
43namespace {
44TimeSpec orwl_gettime() {
45 static double orwl_timebase = 0.0;
46 static uint64_t orwl_timestart = 0;
47
48 // be more careful in a multithreaded environement
49 if (!orwl_timestart) {
50#pragma clang diagnostic push
51#pragma clang diagnostic ignored "-Wmissing-field-initializers"
52 mach_timebase_info_data_t tb = {0};
53#pragma clang diagnostic pop
54 mach_timebase_info(&tb);
55 orwl_timebase = tb.numer;
56 orwl_timebase /= tb.denom;
57 orwl_timestart = mach_absolute_time();
58 }
59 TimeSpec t;
60 double diff = (mach_absolute_time() - orwl_timestart) * orwl_timebase;
61 t.sec = diff * 1e-9;
62 t.nsec = diff - (t.sec * 1e9);
63 return t;
64}
65
66} // anonymous namespace
67

Callers 1

nowMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected