MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / GetPerformanceCounter

Function GetPerformanceCounter

src/random.cpp:56–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56static inline int64_t GetPerformanceCounter()
57{
58 // Read the hardware time stamp counter when available.
59 // See https://en.wikipedia.org/wiki/Time_Stamp_Counter for more information.
60#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
61 return __rdtsc();
62#elif !defined(_MSC_VER) && defined(__i386__)
63 uint64_t r = 0;
64 __asm__ volatile ("rdtsc" : "=A"(r)); // Constrain the r variable to the eax:edx pair.
65 return r;
66#elif !defined(_MSC_VER) && (defined(__x86_64__) || defined(__amd64__))
67 uint64_t r1 = 0, r2 = 0;
68 __asm__ volatile ("rdtsc" : "=a"(r1), "=d"(r2)); // Constrain r1 to rax and r2 to rdx.
69 return (r2 << 32) | r1;
70#else
71 // Fall back to using C++11 clock (usually microsecond or nanosecond precision)
72 return std::chrono::high_resolution_clock::now().time_since_epoch().count();
73#endif
74}
75
76
77#if defined(__x86_64__) || defined(__amd64__) || defined(__i386__)

Callers 3

RandAddSeedFunction · 0.85
RandAddSeedSleepFunction · 0.85
Random_SanityCheckFunction · 0.85

Calls 1

countMethod · 0.45

Tested by

no test coverage detected