diff options
Diffstat (limited to 'bench/MHz.c')
-rw-r--r-- | bench/MHz.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/bench/MHz.c b/bench/MHz.c index 34cac39..874658c 100644 --- a/bench/MHz.c +++ b/bench/MHz.c @@ -51,7 +51,12 @@ void estimate_MHz(struct cpudata *cpu) cycles[1] = rdtsc(); - cpu->MHz = (cycles[1] - cycles[0]) / 1000000; + /* Check to see if rdtsc wrapped */ + if (cycles[1] < cycles[0]) + /* yes we did. */ + cpu->MHz = ((-1ULL - cycles[0]) + cycles[1]) / 1000000; + else + cpu->MHz = (cycles[1] - cycles[0]) / 1000000; if ((cpu->MHz % 50) > 15) cpu->MHz = ((cpu->MHz / 50) * 50) + 50; |