Skip to content

Commit

Permalink
Warn on lack of CPU cycle counter
Browse files Browse the repository at this point in the history
  • Loading branch information
darkk committed Jul 11, 2024
1 parent 67fc076 commit 6bd4345
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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 <strings.h>
#define _stricmp strcasecmp
Expand Down
5 changes: 5 additions & 0 deletions SpeedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 6bd4345

Please sign in to comment.