From 6bd4345bf5c749f19b0742cc8dc60b298619c9b3 Mon Sep 17 00:00:00 2001 From: Leonid Evdokimov Date: Thu, 11 Jul 2024 09:41:22 +0300 Subject: [PATCH] Warn on lack of CPU cycle counter --- Platform.h | 6 ++++++ SpeedTest.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/Platform.h b/Platform.h index 0924c184..609fed64 100644 --- a/Platform.h +++ b/Platform.h @@ -57,6 +57,7 @@ void SetAffinity ( int cpu ); #pragma intrinsic(__rdtsc) // Read Time Stamp Counter +#define timer_counts_ns() (false) #define rdtsc() __rdtsc() #define timer_start() __rdtsc() #define timer_end() __rdtsc() @@ -251,6 +252,11 @@ __inline__ uint64_t timer_end() #endif } +__inline__ bool timer_counts_ns ( void ) +{ + const double ratio = double(timer_start()) / timeofday(); + return (0.999 < ratio && ratio < 1.001); +} #include #define _stricmp strcasecmp diff --git a/SpeedTest.cpp b/SpeedTest.cpp index 0f4efa6c..23db9c46 100644 --- a/SpeedTest.cpp +++ b/SpeedTest.cpp @@ -273,6 +273,11 @@ void BulkSpeedTest ( pfHash hash, uint32_t seed ) const int trials = 2999; const int blocksize = 256 * 1024; + if (timer_counts_ns()) + printf("WARNING: no cycle counter, cycle == 1ns\n"); + if (timer_start() == timer_end()) + printf("WARNING: timer resolution is low\n"); + printf("Bulk speed test - %d-byte keys\n",blocksize); double sumbpc = 0.0;