[cairo-commit] perf/cairo-perf-micro.c

Andrea Canciani ranma42 at kemper.freedesktop.org
Mon Aug 9 10:26:29 PDT 2010


 perf/cairo-perf-micro.c |   17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

New commits:
commit 766832364904dbf5b8a67ebc1600d2ec45d2734f
Author: Andrea Canciani <ranma42 at gmail.com>
Date:   Mon Aug 9 18:47:13 2010 +0200

    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.

diff --git a/perf/cairo-perf-micro.c b/perf/cairo-perf-micro.c
index a12911f..750bac3 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);
 	}
     }
 


More information about the cairo-commit mailing list