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 5adfc52
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions SpeedTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,12 @@ double SpeedTest ( pfHash hash, uint32_t seed, const int trials, const int block
return CalcMean(times);
}

bool timer_counts_ns ( void )
{
const double ratio = double(timer_start()) / timeofday();
return (0.999 < ratio && ratio < 1.001);
}

//-----------------------------------------------------------------------------
// 256k blocks seem to give the best results.

Expand All @@ -273,6 +279,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 5adfc52

Please sign in to comment.