From c062000288b1ab074af65c66cbff05c498205a94 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Mon, 15 Jul 2019 17:20:12 +0300 Subject: [PATCH] Add experimental TSC frequency detection --- Utilities/sysinfo.cpp | 24 +++++++++++++++++++++++- Utilities/sysinfo.h | 2 ++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Utilities/sysinfo.cpp b/Utilities/sysinfo.cpp index 31a6a72424..2f45f56575 100755 --- a/Utilities/sysinfo.cpp +++ b/Utilities/sysinfo.cpp @@ -110,6 +110,15 @@ std::string utils::get_system_info() fmt::append(result, "%s | %d Threads | %.2f GiB RAM", brand, num_proc, mem_total / (1024.0f * 1024 * 1024)); + if (const ullong tsc_freq = get_tsc_freq()) + { + fmt::append(result, " | TSC: %.02fGHz", tsc_freq / 1000000000.); + } + else + { + fmt::append(result, " | TSC: Bad"); + } + if (has_avx()) { result += " | AVX"; @@ -138,7 +147,7 @@ std::string utils::get_system_info() { result += "-FA"; } - + if (!has_mpx()) { result += " disabled by default"; @@ -214,3 +223,16 @@ std::string utils::get_OS_version() #endif return output; } + +ullong utils::get_tsc_freq() +{ +#ifdef _WIN32 + LARGE_INTEGER freq; + if (!QueryPerformanceFrequency(&freq) || freq.QuadPart > 9'999'999) + return 0; + return freq.QuadPart * 1024; +#else + // TODO + return 0; +#endif +} diff --git a/Utilities/sysinfo.h b/Utilities/sysinfo.h index 71d1d2e81b..7479529544 100755 --- a/Utilities/sysinfo.h +++ b/Utilities/sysinfo.h @@ -50,4 +50,6 @@ namespace utils std::string get_firmware_version(); std::string get_OS_version(); + + ullong get_tsc_freq(); }