//时间计算
static int64_t LargeIntegerToInt64(const LARGE_INTEGER& i) {
return ((int64_t)i.HighPart) << 32 | i.LowPart;
}
static int64_t HighResTimer() {
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
return LargeIntegerToInt64(counter);
}
static int64_t TimerToMicros(int64_t dt) {
static int64_t ticks_per_sec = 0;
if (!ticks_per_sec) {
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
ticks_per_sec = LargeIntegerToInt64(freq);
}
// dt is in ticks. We want microseconds.
return (dt * 1000000) / ticks_per_sec;
}
static int64_t LargeIntegerToInt64(const LARGE_INTEGER& i) {
return ((int64_t)i.HighPart) << 32 | i.LowPart;
}
static int64_t HighResTimer() {
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
return LargeIntegerToInt64(counter);
}
static int64_t TimerToMicros(int64_t dt) {
static int64_t ticks_per_sec = 0;
if (!ticks_per_sec) {
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
ticks_per_sec = LargeIntegerToInt64(freq);
}
// dt is in ticks. We want microseconds.
return (dt * 1000000) / ticks_per_sec;
}