diff options
author | Andrea Canciani <ranma42@gmail.com> | 2010-08-09 18:47:13 +0200 |
---|---|---|
committer | Andrea Canciani <ranma42@gmail.com> | 2010-08-09 19:19:04 +0200 |
commit | 766832364904dbf5b8a67ebc1600d2ec45d2734f (patch) | |
tree | ea753e4ad2e9c6833e6f93839558efbcf46fe3f4 /perf | |
parent | 046b642db0782ab5e2a5c82988b21e05afe8e716 (diff) | |
download | cairo-766832364904dbf5b8a67ebc1600d2ec45d2734f.tar.gz |
perf: Improve calibration
Make the loops count depend on the actual calibration_loops/calibration_time
instead of calibration_loops/calibration_max_time.
This avoids having some tests take much less/more than the wanted time per iteration
(I was having some tests taking about 1 second, other taking about 7 seconds when
the ms_per_iteration was 2000)
Spend 0.5-1 times the time wanted for each iteration in calibration, increase the
accuracy of loops count. Just making the loops count be the correct ratio doesn't
guarantee that the iteration time is accurate. By actually measuring iteration
times until it gets greater than 1/4 of the wanted time, the total sum is bound
to be <= the wanted iteration time and last calibration time is between 1/4 and
1/2 of the wanted time, so it should give a very accurate loop count.
Diffstat (limited to 'perf')
-rw-r--r-- | perf/cairo-perf-micro.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/perf/cairo-perf-micro.c b/perf/cairo-perf-micro.c index a12911f5f..750bac364 100644 --- a/perf/cairo-perf-micro.c +++ b/perf/cairo-perf-micro.c @@ -128,18 +128,17 @@ static unsigned cairo_perf_calibrate (cairo_perf_t *perf, cairo_perf_func_t perf_func) { - cairo_perf_ticks_t calibration0, calibration; + cairo_perf_ticks_t calibration, calibration_max; unsigned loops, min_loops; min_loops = 1; - calibration0 = perf_func (perf->cr, perf->size, perf->size, min_loops); - if (perf->fast_and_sloppy) { - calibration = calibration0; - } else { - calibration = 0.01 * cairo_perf_ticks_per_second (); - while (calibration0 < calibration) { - min_loops *= 10; - calibration0 = perf_func (perf->cr, perf->size, perf->size, min_loops); + calibration = perf_func (perf->cr, perf->size, perf->size, min_loops); + + if (!perf->fast_and_sloppy) { + calibration_max = perf->ms_per_iteration * 0.0001 / 4 * cairo_perf_ticks_per_second (); + while (calibration < calibration_max) { + min_loops *= 2; + calibration = perf_func (perf->cr, perf->size, perf->size, min_loops); } } |