Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions interbench.c
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ void calibrate_loop(void)
{
unsigned long long start_time, loops_per_msec, run_time = 0;
struct timespec myts;
unsigned long loops;
unsigned long loops, fail_count = 0, recheck_count = 1;
cpu_set_t cpumask;

CPU_ZERO(&cpumask);
Expand Down Expand Up @@ -1022,12 +1022,18 @@ void calibrate_loop(void)
sleep(1);
loops = loops_per_msec;
start_time = get_nsecs(&myts);
burn_loops(loops);
run_time = get_nsecs(&myts) - start_time;
burn_loops(loops * recheck_count);
run_time = (get_nsecs(&myts) - start_time) / recheck_count;

/* Tolerate 5% difference on checking */
if (run_time > 1050000 || run_time < 950000)
if (run_time > 1050000 || run_time < 950000) {
/* Increase recheck time if 5% margin is missed too often */
if (++fail_count >= 50) {
recheck_count *= 2;
fail_count = 0;
}
goto redo;
}

ud.loops_per_ms = loops_per_msec;
sched_setaffinity(0, sizeof(ud.cpumask), &ud.cpumask);
Expand Down