[cairo-commit] perf/micro

Chris Wilson ickle at kemper.freedesktop.org
Sun Aug 7 04:28:04 PDT 2011


 perf/micro/many-strokes.c |  110 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 109 insertions(+), 1 deletion(-)

New commits:
commit f646cb07a93975a67ed3b9ba1b468b014fcf1675
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Aug 7 12:26:41 2011 +0100

    perf: add the usual special cases to many-strokes
    
    For completeness, also compare [aligned] horizontal and vertical
    strokes.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/perf/micro/many-strokes.c b/perf/micro/many-strokes.c
index b6211f2..f5b3a8c 100644
--- a/perf/micro/many-strokes.c
+++ b/perf/micro/many-strokes.c
@@ -39,6 +39,110 @@ uniform_random (double minval, double maxval)
 }
 
 static cairo_perf_ticks_t
+do_many_strokes_ha (cairo_t *cr, int width, int height, int loops)
+{
+    int count;
+
+    state = 0xc0ffee;
+    for (count = 0; count < 1000; count++) {
+	double h = floor (uniform_random (0, height));
+	cairo_move_to (cr, floor (uniform_random (0, width)), h);
+	cairo_line_to (cr, ceil (uniform_random (0, width)), h);
+    }
+
+    cairo_set_line_width (cr, 2.);
+
+    cairo_perf_timer_start ();
+
+    while (loops--)
+	cairo_stroke_preserve (cr);
+
+    cairo_perf_timer_stop ();
+
+    cairo_new_path (cr);
+
+    return cairo_perf_timer_elapsed ();
+}
+
+static cairo_perf_ticks_t
+do_many_strokes_h (cairo_t *cr, int width, int height, int loops)
+{
+    int count;
+
+    state = 0xc0ffee;
+    for (count = 0; count < 1000; count++) {
+	double h = uniform_random (0, height);
+	cairo_move_to (cr, uniform_random (0, width), h);
+	cairo_line_to (cr, uniform_random (0, width), h);
+    }
+
+    cairo_set_line_width (cr, 2.);
+
+    cairo_perf_timer_start ();
+
+    while (loops--)
+	cairo_stroke_preserve (cr);
+
+    cairo_perf_timer_stop ();
+
+    cairo_new_path (cr);
+
+    return cairo_perf_timer_elapsed ();
+}
+
+static cairo_perf_ticks_t
+do_many_strokes_va (cairo_t *cr, int width, int height, int loops)
+{
+    int count;
+
+    state = 0xc0ffee;
+    for (count = 0; count < 1000; count++) {
+	double v = floor (uniform_random (0, width));
+	cairo_move_to (cr, v, floor (uniform_random (0, height)));
+	cairo_line_to (cr, v, ceil (uniform_random (0, height)));
+    }
+
+    cairo_set_line_width (cr, 2.);
+
+    cairo_perf_timer_start ();
+
+    while (loops--)
+	cairo_stroke_preserve (cr);
+
+    cairo_perf_timer_stop ();
+
+    cairo_new_path (cr);
+
+    return cairo_perf_timer_elapsed ();
+}
+
+static cairo_perf_ticks_t
+do_many_strokes_v (cairo_t *cr, int width, int height, int loops)
+{
+    int count;
+
+    state = 0xc0ffee;
+    for (count = 0; count < 1000; count++) {
+	double v = uniform_random (0, width);
+	cairo_move_to (cr, v, uniform_random (0, height));
+	cairo_line_to (cr, v, uniform_random (0, height));
+    }
+
+    cairo_set_line_width (cr, 2.);
+
+    cairo_perf_timer_start ();
+
+    while (loops--)
+	cairo_stroke_preserve (cr);
+
+    cairo_perf_timer_stop ();
+
+    cairo_new_path (cr);
+
+    return cairo_perf_timer_elapsed ();
+}
+
+static cairo_perf_ticks_t
 do_many_strokes (cairo_t *cr, int width, int height, int loops)
 {
     int count;
@@ -71,5 +175,9 @@ many_strokes (cairo_perf_t *perf, cairo_t *cr, int width, int height)
     if (! cairo_perf_can_run (perf, "many-strokes", NULL))
 	return;
 
-    cairo_perf_run (perf, "many-strokes", do_many_strokes, NULL);
+    cairo_perf_run (perf, "many-strokes-halign", do_many_strokes_ha, NULL);
+    cairo_perf_run (perf, "many-strokes-valign", do_many_strokes_va, NULL);
+    cairo_perf_run (perf, "many-strokes-horizontal", do_many_strokes_h, NULL);
+    cairo_perf_run (perf, "many-strokes-vertical", do_many_strokes_v, NULL);
+    cairo_perf_run (perf, "many-strokes-random", do_many_strokes, NULL);
 }


More information about the cairo-commit mailing list