Separation and small optimization. v0.7.1.0

This commit is contained in:
korenkonder
2023-02-12 04:13:59 +03:00
parent f0392bd166
commit df3167787f
197 changed files with 44235 additions and 23661 deletions
+33
View File
@@ -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(&timestamp))
return 0;
return (double_t)(timestamp.QuadPart - this->timestamp.QuadPart) * inv_freq;
}
void time_struct::get_timestamp() {
if (!QueryPerformanceCounter(&timestamp))
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;
}