[cairo-commit] 6 commits - perf/cairo-perf.c perf/cairo-perf-diff-files.c perf/fill.c perf/long-lines.c

Chris Wilson ickle at kemper.freedesktop.org
Fri Jul 31 01:44:04 PDT 2009


 perf/cairo-perf-diff-files.c |   11 ++++++---
 perf/cairo-perf.c            |   19 ++++++++++++++++
 perf/fill.c                  |   37 ++++++++++++++++++++++++++++++++
 perf/long-lines.c            |   49 +++++++++++++++++++++++++++++++------------
 4 files changed, 99 insertions(+), 17 deletions(-)

New commits:
commit ce8a8424aa4331f119b115123faf7b773b5f25d0
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jul 31 09:36:10 2009 +0100

    [perf] Change the order of slowdowns.
    
    More the large slowdowns to the end. This has two pleasing effects:
    
      1. There is symmetry between large speedups at the top, and large
         slowdowns at the bottom, with long bars -> short bars -> long bars.
    
      2. After a cairo-perf-diff run the largest slowdowns are immediately
         visible on the console. What better way to flag performance
         regressions?

diff --git a/perf/cairo-perf-diff-files.c b/perf/cairo-perf-diff-files.c
index adbe69a..6870b80 100644
--- a/perf/cairo-perf-diff-files.c
+++ b/perf/cairo-perf-diff-files.c
@@ -60,12 +60,15 @@ test_diff_cmp_speedup_before_slowdown (const void *a, const void *b)
     if (a_diff->change < 1.0 && b_diff->change > 1.0)
 	return 1;
 
-    /* Reverse sort by magnitude of change so larger changes come
-     * first */
-    if (fabs (a_diff->change) > fabs (b_diff->change))
+    if (a_diff->change == b_diff->change)
+	return 0;
+
+    /* Large speedups come first. */
+    if (a_diff->change > 1. && a_diff->change > b_diff->change)
 	return -1;
 
-    if (fabs (a_diff->change) < fabs (b_diff->change))
+    /* Large slowdowns come last. */
+    if (a_diff->change < 1. && a_diff->change < b_diff->change)
 	return 1;
 
     return 0;
commit 877ed645f95ff048f7c5d2ce0fb92389918711a6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jul 30 22:09:55 2009 +0100

    [perf] Add a more complex fill, a set of rings
    
    In investigating performance regressions with the wip/tessellator, I'm
    keen to inspect how the tessellator scales with polygon complexity.

diff --git a/perf/fill.c b/perf/fill.c
index f068561..0bad3cd 100644
--- a/perf/fill.c
+++ b/perf/fill.c
@@ -43,6 +43,42 @@ do_fill (cairo_t *cr, int width, int height)
 }
 
 static cairo_perf_ticks_t
+do_fill_annuli (cairo_t *cr, int width, int height)
+{
+    cairo_new_sub_path (cr);
+    cairo_arc (cr,
+	       width/2.0, height/2.0,
+	       width/3.0,
+	       0, 2 * M_PI);
+
+    cairo_new_sub_path (cr);
+    cairo_arc_negative (cr,
+	       width/2.0, height/2.0,
+	       width/4.0,
+	       2 * M_PI, 0);
+
+    cairo_new_sub_path (cr);
+    cairo_arc (cr,
+	       width/2.0, height/2.0,
+	       width/6.0,
+	       0, 2 * M_PI);
+
+    cairo_new_sub_path (cr);
+    cairo_arc_negative (cr,
+	       width/2.0, height/2.0,
+	       width/8.0,
+	       2 * M_PI, 0);
+
+    cairo_perf_timer_start ();
+
+    cairo_fill (cr);
+
+    cairo_perf_timer_stop ();
+
+    return cairo_perf_timer_elapsed ();
+}
+
+static cairo_perf_ticks_t
 do_fill_eo_noaa (cairo_t *cr, int width, int height)
 {
     cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
@@ -69,5 +105,6 @@ fill (cairo_perf_t *perf, cairo_t *cr, int width, int height)
 	return;
 
     cairo_perf_cover_sources_and_operators (perf, "fill", do_fill);
+    cairo_perf_cover_sources_and_operators (perf, "fill-annuli", do_fill_annuli);
     cairo_perf_cover_sources_and_operators (perf, "fill-eo-noaa", do_fill_eo_noaa);
 }
commit 3dbc4170f0e89f02455b82c6496d6322e56e0491
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jul 30 10:35:11 2009 +0100

    [perf] Add a single shot long-lines
    
    Compare the performance of self-intersection removal by comparing the cost
    of individually stroking each line versus stroking them all en-mass.

diff --git a/perf/long-lines.c b/perf/long-lines.c
index 2b1192b..67f698a 100644
--- a/perf/long-lines.c
+++ b/perf/long-lines.c
@@ -35,7 +35,10 @@
  * same lines, (this is the "long-lines-cropped" report).
  */
 
-typedef enum { LONG_LINES_UNCROPPED, LONG_LINES_CROPPED } long_lines_crop_t;
+typedef enum {
+    LONG_LINES_CROPPED = 0x1,
+    LONG_LINES_ONCE = 0x2,
+} long_lines_crop_t;
 #define NUM_LINES    20
 #define LONG_FACTOR  50.0
 
@@ -50,14 +53,14 @@ do_long_lines (cairo_t *cr, int width, int height, long_lines_crop_t crop)
 
     cairo_translate (cr, width / 2, height / 2);
 
-    if (crop == LONG_LINES_UNCROPPED) {
-	outer_width = LONG_FACTOR * width;
-	outer_height = LONG_FACTOR * height;
-	cairo_set_source_rgb (cr, 1.0, 0.0, 0.0); /* red */
-    } else {
+    if (crop & LONG_LINES_CROPPED) {
 	outer_width = width;
 	outer_height = height;
 	cairo_set_source_rgb (cr, 0.0, 1.0, 0.0); /* green */
+    } else {
+	outer_width = LONG_FACTOR * width;
+	outer_height = LONG_FACTOR * height;
+	cairo_set_source_rgb (cr, 1.0, 0.0, 0.0); /* red */
     }
 
     min_x = x = - outer_width / 2.0;
@@ -72,23 +75,29 @@ do_long_lines (cairo_t *cr, int width, int height, long_lines_crop_t crop)
     for (i = 0; i <= NUM_LINES; i++) {
 	cairo_move_to (cr, 0, 0);
 	cairo_line_to (cr, x, min_y);
-	cairo_stroke (cr);
+	if ((crop & LONG_LINES_ONCE) == 0)
+	    cairo_stroke (cr);
 
 	cairo_move_to (cr, 0, 0);
 	cairo_line_to (cr, x, max_y);
-	cairo_stroke (cr);
+	if ((crop & LONG_LINES_ONCE) == 0)
+	    cairo_stroke (cr);
 
 	cairo_move_to (cr, 0, 0);
 	cairo_line_to (cr, min_x, y);
-	cairo_stroke (cr);
+	if ((crop & LONG_LINES_ONCE) == 0)
+	    cairo_stroke (cr);
 
 	cairo_move_to (cr, 0, 0);
 	cairo_line_to (cr, max_x, y);
-	cairo_stroke (cr);
+	if ((crop & LONG_LINES_ONCE) == 0)
+	    cairo_stroke (cr);
 
 	x += dx;
 	y += dy;
     }
+    if (crop & LONG_LINES_ONCE)
+	cairo_stroke (cr);
 
     cairo_perf_timer_stop ();
 
@@ -100,7 +109,13 @@ do_long_lines (cairo_t *cr, int width, int height, long_lines_crop_t crop)
 static cairo_perf_ticks_t
 long_lines_uncropped (cairo_t *cr, int width, int height)
 {
-    return do_long_lines (cr, width, height, LONG_LINES_UNCROPPED);
+    return do_long_lines (cr, width, height, 0);
+}
+
+static cairo_perf_ticks_t
+long_lines_uncropped_once (cairo_t *cr, int width, int height)
+{
+    return do_long_lines (cr, width, height, LONG_LINES_ONCE);
 }
 
 static cairo_perf_ticks_t
@@ -109,6 +124,12 @@ long_lines_cropped (cairo_t *cr, int width, int height)
     return do_long_lines (cr, width, height, LONG_LINES_CROPPED);
 }
 
+static cairo_perf_ticks_t
+long_lines_cropped_once (cairo_t *cr, int width, int height)
+{
+    return do_long_lines (cr, width, height, LONG_LINES_CROPPED | LONG_LINES_ONCE);
+}
+
 void
 long_lines (cairo_perf_t *perf, cairo_t *cr, int width, int height)
 {
@@ -116,5 +137,7 @@ long_lines (cairo_perf_t *perf, cairo_t *cr, int width, int height)
 	return;
 
     cairo_perf_run (perf, "long-lines-uncropped", long_lines_uncropped);
+    cairo_perf_run (perf, "long-lines-uncropped-once", long_lines_uncropped_once);
     cairo_perf_run (perf, "long-lines-cropped", long_lines_cropped);
+    cairo_perf_run (perf, "long-lines-cropped-once", long_lines_cropped_once);
 }
commit 2f033af5ab15dc56675c42434bb1c18655012b03
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jul 30 09:42:31 2009 +0100

    [perf] Fix the asymmetry in long lines
    
    We missed the final long diagonal to the bottom-right.

diff --git a/perf/long-lines.c b/perf/long-lines.c
index 3a57418..2b1192b 100644
--- a/perf/long-lines.c
+++ b/perf/long-lines.c
@@ -69,7 +69,7 @@ do_long_lines (cairo_t *cr, int width, int height, long_lines_crop_t crop)
 
     cairo_perf_timer_start ();
 
-    for (i = 0; i < NUM_LINES; i++) {
+    for (i = 0; i <= NUM_LINES; i++) {
 	cairo_move_to (cr, 0, 0);
 	cairo_line_to (cr, x, min_y);
 	cairo_stroke (cr);
commit 944206e55ba997a4a55334be3c7ebf8141016be7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Jul 30 09:36:28 2009 +0100

    [perf] Correct typo in long-lines.c
    
    Computed may_y using height not width, fortunately the test cases have
    always been square.

diff --git a/perf/long-lines.c b/perf/long-lines.c
index 0359201..3a57418 100644
--- a/perf/long-lines.c
+++ b/perf/long-lines.c
@@ -63,7 +63,7 @@ do_long_lines (cairo_t *cr, int width, int height, long_lines_crop_t crop)
     min_x = x = - outer_width / 2.0;
     min_y = y = - outer_height / 2.0;
     max_x = outer_width / 2.0;
-    max_y = outer_width / 2.0;
+    max_y = outer_height / 2.0;
     dx = outer_width / NUM_LINES;
     dy = outer_height / NUM_LINES;
 
commit 229887e980f03d90248add8af9cd0a9be6cb0f9a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Jul 29 19:48:00 2009 +0100

    [perf] Check output
    
    Add a CAIRO_PERF_OUTPUT environment variable to cause cairo-perf to first
    generate an output image in order to manually check that the test is
    functioning correctly. This needs to be automated, so that we have
    absolute confidence that the performance tests are not broken - but isn't
    that the role of the test suite? If we were ever to publish cairo-perf
    results, I would want some means of verification that the test-suite had
    first been passed.

diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
index f3b5f66..792120b 100644
--- a/perf/cairo-perf.c
+++ b/perf/cairo-perf.c
@@ -200,6 +200,25 @@ cairo_perf_run (cairo_perf_t		*perf,
 
     times = perf->times;
 
+    if (getenv ("CAIRO_PERF_OUTPUT") != NULL) { /* check output */
+	char *filename;
+	cairo_status_t status;
+
+	xasprintf (&filename, "%s.%s.%s.%d.out.png",
+		   name, perf->target->name,
+		   _content_to_string (perf->target->content, 0),
+		   perf->size);
+	perf_func (perf->cr, perf->size, perf->size);
+	status = cairo_surface_write_to_png (cairo_get_target (perf->cr), filename);
+	if (status) {
+	    fprintf (stderr, "Failed to generate output check '%s': %s\n",
+		     filename, cairo_status_to_string (status));
+	    return;
+	}
+
+	free (filename);
+    }
+
     has_similar = cairo_perf_has_similar (perf);
     for (similar = 0; similar <= has_similar; similar++) {
 	if (perf->summary) {


More information about the cairo-commit mailing list