[cairo-commit] 3 commits - perf/cairo-perf.c perf/cairo-perf.h perf/paint.c

Carl Worth cworth at kemper.freedesktop.org
Thu Aug 31 11:53:20 PDT 2006


 perf/cairo-perf.c |   24 ++++++++++++++----------
 perf/cairo-perf.h |    7 +++----
 perf/paint.c      |   35 ++++++++++++++++++++---------------
 3 files changed, 37 insertions(+), 29 deletions(-)

New commits:
diff-tree 7917e1201fd38089111bb7723256747ae32347e0 (from 0c741675e1d43168f42ee530486bfa4b8ec54920)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Aug 31 11:53:16 2006 -0700

    perf: Fix typo in backend blackballing so that image tests now run

diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index ac14cf6..c442afb 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -50,8 +50,8 @@ target_is_measurable (cairo_test_target_
 {
     switch (target->expected_type) {
     case CAIRO_SURFACE_TYPE_IMAGE:
-	if (strcmp (target->name, "pdf") ||
-	    strcmp (target->name, "ps"))
+	if (strcmp (target->name, "pdf") == 0 ||
+	    strcmp (target->name, "ps") == 0)
 	{
 	    return FALSE;
 	}
diff-tree 0c741675e1d43168f42ee530486bfa4b8ec54920 (from fd13e874a778eeac4e2d358cc19b040aa20bcdf3)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Aug 31 11:51:28 2006 -0700

    Make perf interface return a rate. Start print target and test names.

diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index f9faf3c..ac14cf6 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -38,11 +38,7 @@ typedef struct _cairo_perf {
     unsigned int max_size;
 } cairo_perf_t;
 
-cairo_perf_t perfs[] = {
-    { "paint", paint, 32, 1024 },
-    { "paint_alpha", paint_alpha, 32, 1024 },
-    { NULL }
-};
+cairo_perf_t perfs[];
 
 /* Some targets just aren't that interesting for performance testing,
  * (not least because many of these surface types use a meta-surface
@@ -88,6 +84,7 @@ main (int argc, char *argv[])
     cairo_surface_t *surface;
     cairo_t *cr;
     unsigned int size;
+    double rate;
 
     if (getenv("CAIRO_PERF_DURATION"))
 	cairo_perf_duration = strtol(getenv("CAIRO_PERF_DURATION"), NULL, 0);
@@ -104,7 +101,11 @@ main (int argc, char *argv[])
 							   size, size,
 							   &target->closure);
 		cr = cairo_create (surface);
-		perf->run (cr, size, size);
+		rate = perf->run (cr, size, size);
+		if (perf->min_size == perf->max_size)
+		    printf ("%s\t%s\t%g\n", target->name, perf->name, rate);
+		else
+		    printf ("%s\t%s-%d\t%g\n", target->name, perf->name, size, rate);
 	    }
 	}
     }
@@ -112,3 +113,8 @@ main (int argc, char *argv[])
     return 0;
 }
 
+cairo_perf_t perfs[] = {
+    { "paint", paint, 32, 1024 },
+    { "paint_alpha", paint_alpha, 32, 1024 },
+    { NULL }
+};
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
index 6300de0..a913b81 100644
--- a/perf/cairo-perf.h
+++ b/perf/cairo-perf.h
@@ -64,9 +64,9 @@ extern int cairo_perf_alarm_expired;
 #define CAIRO_PERF_LOOP_RATE(timervar)		\
     ((timervar).count) / timer_elapsed (&(timervar))
 
-typedef void (*cairo_perf_func_t) (cairo_t *cr, int width, int height);
+typedef double (*cairo_perf_func_t) (cairo_t *cr, int width, int height);
 
-#define CAIRO_PERF_DECL(func) void func (cairo_t *cr, int width, int height)
+#define CAIRO_PERF_DECL(func) double func (cairo_t *cr, int width, int height)
 
 CAIRO_PERF_DECL (paint);
 CAIRO_PERF_DECL (paint_alpha);
diff --git a/perf/paint.c b/perf/paint.c
index 3a0cd11..2f47d74 100644
--- a/perf/paint.c
+++ b/perf/paint.c
@@ -25,7 +25,7 @@
 
 #include "cairo-perf.h"
 
-static void
+static double
 do_paint (cairo_t *cr)
 {
     cairo_perf_timer_t timer;
@@ -36,22 +36,22 @@ do_paint (cairo_t *cr)
     }
     CAIRO_PERF_LOOP_FINI (timer);
 
-    printf ("Rate: %g\n", CAIRO_PERF_LOOP_RATE (timer));
+    return CAIRO_PERF_LOOP_RATE (timer);
 }
 
-void
+double
 paint (cairo_t *cr, int width, int height)
 {
     cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
 
-    do_paint (cr);
+    return do_paint (cr);
 }
 
-void
+double
 paint_alpha (cairo_t *cr, int width, int height)
 {
     cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
 
-    do_paint (cr);
+    return do_paint (cr);
 }
 
diff-tree fd13e874a778eeac4e2d358cc19b040aa20bcdf3 (from 578b74473de4c70f907db38eac6f8e9039d72aa1)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Aug 31 11:42:51 2006 -0700

    perf: Drop separate setup function from each test case.
    
    We are already doing loop measurement internally, so each function
    can already do any setup it needs without it affecting the measurement.

diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index 1f7e167..f9faf3c 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -33,15 +33,14 @@ int cairo_perf_alarm_expired = 0;
 
 typedef struct _cairo_perf {
     const char *name;
-    cairo_perf_func_t setup;
     cairo_perf_func_t run;
     unsigned int min_size;
     unsigned int max_size;
 } cairo_perf_t;
 
 cairo_perf_t perfs[] = {
-    { "paint", paint_setup, paint, 32, 1024 },
-    { "paint_alpha", paint_alpha_setup, paint, 32, 1024 },
+    { "paint", paint, 32, 1024 },
+    { "paint_alpha", paint_alpha, 32, 1024 },
     { NULL }
 };
 
@@ -105,7 +104,6 @@ main (int argc, char *argv[])
 							   size, size,
 							   &target->closure);
 		cr = cairo_create (surface);
-		perf->setup (cr, size, size);
 		perf->run (cr, size, size);
 	    }
 	}
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
index 5c06d32..6300de0 100644
--- a/perf/cairo-perf.h
+++ b/perf/cairo-perf.h
@@ -68,8 +68,7 @@ typedef void (*cairo_perf_func_t) (cairo
 
 #define CAIRO_PERF_DECL(func) void func (cairo_t *cr, int width, int height)
 
-CAIRO_PERF_DECL (paint_setup);
-CAIRO_PERF_DECL (paint_alpha_setup);
 CAIRO_PERF_DECL (paint);
+CAIRO_PERF_DECL (paint_alpha);
 
 #endif
diff --git a/perf/paint.c b/perf/paint.c
index d077c04..3a0cd11 100644
--- a/perf/paint.c
+++ b/perf/paint.c
@@ -25,28 +25,33 @@
 
 #include "cairo-perf.h"
 
-void
-paint_setup (cairo_t *cr, int width, int height)
+static void
+do_paint (cairo_t *cr)
 {
-    cairo_set_source_rgba (cr, 1.0, 0.2, 0.6, 0.5);
+    cairo_perf_timer_t timer;
+
+    CAIRO_PERF_LOOP_INIT (timer);
+    {
+	cairo_paint (cr);
+    }
+    CAIRO_PERF_LOOP_FINI (timer);
+
+    printf ("Rate: %g\n", CAIRO_PERF_LOOP_RATE (timer));
 }
 
 void
-paint_alpha_setup (cairo_t *cr, int width, int height)
+paint (cairo_t *cr, int width, int height)
 {
     cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
+
+    do_paint (cr);
 }
 
 void
-paint (cairo_t *cr, int width, int height)
+paint_alpha (cairo_t *cr, int width, int height)
 {
-    cairo_perf_timer_t timer;
-
-    CAIRO_PERF_LOOP_INIT (timer);
-    {
-	cairo_paint (cr);
-    }
-    CAIRO_PERF_LOOP_FINI (timer);
+    cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
 
-    printf ("Rate: %g\n", CAIRO_PERF_LOOP_RATE (timer));
+    do_paint (cr);
 }
+


More information about the cairo-commit mailing list