From a771d65d2e2f6966d3efd0a1018fd55632d31a66 Mon Sep 17 00:00:00 2001 From: cdozdil Date: Wed, 4 Sep 2024 22:02:51 +0300 Subject: [PATCH] added get milliseconds --- OptiScaler/Util.cpp | 20 ++++++++++++++++++++ OptiScaler/Util.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/OptiScaler/Util.cpp b/OptiScaler/Util.cpp index 563b477b..bbdba8b4 100644 --- a/OptiScaler/Util.cpp +++ b/OptiScaler/Util.cpp @@ -51,6 +51,26 @@ std::optional Util::NvngxPath() return result; } +double Util::MillisecondsNow() +{ + static LARGE_INTEGER s_frequency; + static BOOL s_use_qpc = QueryPerformanceFrequency(&s_frequency); + double milliseconds = 0; + + if (s_use_qpc) + { + LARGE_INTEGER now; + QueryPerformanceCounter(&now); + milliseconds = double(1000.0 * now.QuadPart) / s_frequency.QuadPart; + } + else + { + milliseconds = double(GetTickCount64()); + } + + return milliseconds; +} + std::filesystem::path Util::ExePath() { static std::filesystem::path exe; diff --git a/OptiScaler/Util.h b/OptiScaler/Util.h index 84ab9827..bdfeebda 100644 --- a/OptiScaler/Util.h +++ b/OptiScaler/Util.h @@ -6,6 +6,8 @@ namespace Util std::filesystem::path ExePath(); std::filesystem::path DllPath(); std::optional NvngxPath(); + double MillisecondsNow(); + HWND GetProcessWindow(); };