mirror of
https://github.com/korenkonder/ReDIVA.git
synced 2026-10-13 09:38:14 +03:00
Separation and small optimization. v0.7.1.0
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
by korenkonder
|
||||
GitHub/GitLab: korenkonder
|
||||
*/
|
||||
|
||||
#include "time.hpp"
|
||||
|
||||
static double_t time_struct_get_freq();
|
||||
|
||||
time_struct::time_struct() : timestamp() {
|
||||
get_timestamp();
|
||||
inv_freq = time_struct_get_freq();
|
||||
}
|
||||
|
||||
double_t time_struct::calc_time() {
|
||||
LARGE_INTEGER timestamp;
|
||||
if (!QueryPerformanceCounter(×tamp))
|
||||
return 0;
|
||||
|
||||
return (double_t)(timestamp.QuadPart - this->timestamp.QuadPart) * inv_freq;
|
||||
}
|
||||
|
||||
void time_struct::get_timestamp() {
|
||||
if (!QueryPerformanceCounter(×tamp))
|
||||
timestamp.QuadPart = 0;
|
||||
}
|
||||
|
||||
static double_t time_struct_get_freq() {
|
||||
LARGE_INTEGER freq;
|
||||
if (QueryPerformanceFrequency(&freq))
|
||||
return 1000.0 / (double_t)freq.LowPart;
|
||||
return 0.0;
|
||||
}
|
||||
Reference in New Issue
Block a user