[cairo-commit] 2 commits - perf/cairo-perf.c test/pattern-getters.c

Carl Worth cworth at kemper.freedesktop.org
Thu Oct 12 16:05:15 PDT 2006


 perf/cairo-perf.c      |   32 ++++++++++++++++++++++++--------
 test/pattern-getters.c |    8 ++++----
 2 files changed, 28 insertions(+), 12 deletions(-)

New commits:
diff-tree 648f4bc830ab7cc89ffa2ba03d2757d0979a5671 (from 78ad834d81b1fb2a49150ce224a5f25b5190b5a4)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Oct 12 15:12:01 2006 -0700

    perf: Make iterations adaptive (bailing as soon as std. deviation is <= 3% for 5 consecutive iterations
    
    This makes the entire performance test suite about 10 times faster
    on my system. And I don't think that the results are significantly
    worse, (many tests are stable after only 5 iterations while some
    still run to 100 iterations without reaching our stability criteria).

diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index 0b856a8..3af389b 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -28,6 +28,10 @@
 
 #include "cairo-perf.h"
 
+#define CAIRO_PERF_ITERATIONS_DEFAULT	100
+#define CAIRO_PERF_LOW_STD_DEV		0.03
+#define CAIRO_PERF_STABLE_STD_DEV_COUNT	5
+
 typedef struct _cairo_perf_case {
     CAIRO_PERF_DECL (*run);
     unsigned int min_size;
@@ -140,19 +144,31 @@ cairo_perf_run (cairo_perf_t		*perf,
     unsigned int i;
     cairo_perf_ticks_t *times;
     stats_t stats;
+    int low_std_dev_count;
 
     times = xmalloc (perf->iterations * sizeof (cairo_perf_ticks_t));
 
+    low_std_dev_count = 0;
     for (i =0; i < perf->iterations; i++) {
 	cairo_perf_yield ();
 	times[i] = (perf_func) (perf->cr, perf->size, perf->size);
-    }
-
-    qsort (times, perf->iterations,
-	   sizeof (cairo_perf_ticks_t), compare_cairo_perf_ticks);
 
-    /* Assume the slowest 15% are outliers, and ignore */
-    _compute_stats (times, .85 * perf->iterations, &stats);
+	if (i > 0) {
+	    qsort (times, i+1,
+		   sizeof (cairo_perf_ticks_t), compare_cairo_perf_ticks);
+
+	    /* Assume the slowest 15% are outliers, and ignore */
+	    _compute_stats (times, .85 * (i+1), &stats);
+
+	    if (stats.std_dev <= CAIRO_PERF_LOW_STD_DEV) {
+		low_std_dev_count++;
+		if (low_std_dev_count >= CAIRO_PERF_STABLE_STD_DEV_COUNT)
+		    break;
+	    } else {
+		low_std_dev_count = 0;
+	    }
+	}
+    }
 
     if (first_run) {
 	printf ("[ # ] %8s-%-4s %36s %9s %5s %s\n",
@@ -168,7 +184,7 @@ cairo_perf_run (cairo_perf_t		*perf,
 
     printf ("%#9.3f %#5.2f%% % 5d\n",
 	    (stats.mean * 1000.0) / cairo_perf_ticks_per_second (),
-	    stats.std_dev * 100.0, perf->iterations);
+	    stats.std_dev * 100.0, i);
 
     perf->test_number++;
 }
@@ -186,7 +202,7 @@ main (int argc, char *argv[])
     if (getenv("CAIRO_PERF_ITERATIONS"))
 	perf.iterations = strtol(getenv("CAIRO_PERF_ITERATIONS"), NULL, 0);
     else
-	perf.iterations = 100;
+	perf.iterations = CAIRO_PERF_ITERATIONS_DEFAULT;
 
     for (i = 0; targets[i].name; i++) {
 	perf.target = target = &targets[i];
diff-tree 78ad834d81b1fb2a49150ce224a5f25b5190b5a4 (from 20375d5cef560e7277635a0bdba3872f31cb4479)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Oct 12 14:21:55 2006 -0700

    Fix typo of , instead of || which was causing a test to be ignored
    
    Thanks to a gcc warning for catching this one, (statement with
    no effect, or similar).

diff --git a/test/pattern-getters.c b/test/pattern-getters.c
index db3d327..fcfd0b9 100644
--- a/test/pattern-getters.c
+++ b/test/pattern-getters.c
@@ -40,7 +40,7 @@ cairo_test_t test = {
 
 #define DOUBLE_EQUALS(a,b)  (fabs((a)-(b)) < 0.00001)
 
-int
+static int
 double_buf_equal (double *a, double *b, int nc)
 {
     int i;
@@ -65,9 +65,9 @@ draw (cairo_t *cr, int width, int height
 	status = cairo_pattern_get_rgba (pat, &r, &g, &b, &a);
 	CHECK_SUCCESS;
 
-	if (!DOUBLE_EQUALS(r,0.2),
-	    !DOUBLE_EQUALS(g,0.3),
-	    !DOUBLE_EQUALS(b,0.4),
+	if (!DOUBLE_EQUALS(r,0.2) ||
+	    !DOUBLE_EQUALS(g,0.3) ||
+	    !DOUBLE_EQUALS(b,0.4) ||
 	    !DOUBLE_EQUALS(a,0.5))
 	    return CAIRO_TEST_FAILURE;
 


More information about the cairo-commit mailing list