[cairo-commit] configure.in Makefile.am perf/cairo-perf.c perf/cairo-perf.h perf/.gitignore perf/Makefile.am perf/paint.c

Carl Worth cworth at kemper.freedesktop.org
Thu Aug 31 07:51:34 PDT 2006


 Makefile.am       |    2 +
 configure.in      |    1 
 perf/.gitignore   |    2 +
 perf/Makefile.am  |   26 +++++++++++++++++++
 perf/cairo-perf.c |   72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 perf/cairo-perf.h |   45 +++++++++++++++++++++++++++++++++
 perf/paint.c      |   49 ++++++++++++++++++++++++++++++++++++
 7 files changed, 197 insertions(+)

New commits:
diff-tree e153c55dffca6b95a8ad9c731156a579f8979f42 (from d1834cca192fe6f8e429be0461fab6914e04024d)
Author: Carl Worth <cworth at cworth.org>
Date:   Thu Aug 31 07:19:05 2006 -0700

    perf: Add initial skeleton of performance monitoring suite

diff --git a/Makefile.am b/Makefile.am
index 5f376d4..efc2bba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -12,6 +12,8 @@ recheck: all
 	cd test && $(MAKE) $(AM_MAKEFLAGS) recheck
 check-valgrind: all
 	cd test && $(MAKE) $(AM_MAKEFLAGS) check-valgrind
+perf: all
+	cd perf && $(MAKE) $(AM_MAKEFLAGS) perf
 
 # libpng is required for our test programs
 if CAIRO_HAS_PNG_FUNCTIONS
diff --git a/configure.in b/configure.in
index fbcf945..dd06b8a 100644
--- a/configure.in
+++ b/configure.in
@@ -784,6 +784,7 @@ pixman/Makefile
 pixman/src/Makefile
 src/Makefile
 test/Makefile
+perf/Makefile
 doc/Makefile
 doc/public/Makefile
 doc/public/version.xml
diff --git a/perf/.gitignore b/perf/.gitignore
new file mode 100644
index 0000000..e219350
--- /dev/null
+++ b/perf/.gitignore
@@ -0,0 +1,2 @@
+cairo-perf
+*-out.ps
diff --git a/perf/Makefile.am b/perf/Makefile.am
new file mode 100644
index 0000000..08223ca
--- /dev/null
+++ b/perf/Makefile.am
@@ -0,0 +1,26 @@
+SUBDIRS=../boilerplate
+
+# We're using _GNU_SOURCE to get the prototype for asprintf. This may
+# not be the most portable approach, but it is pragmatic and I'm
+# willing to do something cleaner as soon as it causes someone a
+# problem.
+INCLUDES =					\
+	-D_GNU_SOURCE				\
+	-I$(srcdir)				\
+	-I$(top_srcdir)/boilerplate		\
+	-I$(top_srcdir)/src			\
+	$(CAIRO_CFLAGS)
+
+noinst_PROGRAMS = cairo-perf
+
+cairo_perf_SOURCES =	\
+	cairo-perf.c	\
+	cairo-perf.h	\
+	paint.c
+
+LDADD = $(top_builddir)/boilerplate/libcairoboilerplate.la \
+	$(top_builddir)/src/libcairo.la
+
+perf: cairo-perf
+	./cairo-perf
+
diff --git a/perf/cairo-perf.c b/perf/cairo-perf.c
new file mode 100644
index 0000000..0c64c3b
--- /dev/null
+++ b/perf/cairo-perf.c
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-perf.h"
+
+unsigned int iterations = 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 },
+    { NULL }
+};
+
+int
+main (int argc, char *argv[])
+{
+    int i, j;
+    cairo_test_target_t *target;
+    cairo_perf_t *perf;
+    cairo_surface_t *surface;
+    cairo_t *cr;
+    unsigned int size;
+
+    for (i = 0; targets[i].name; i++) {
+	target = &targets[i];
+	for (j = 0; perfs[j].name; j++) {
+	    perf = &perfs[j];
+	    for (size = perf->min_size; size <= perf->max_size; size *= 2) {
+		surface = (target->create_target_surface) (perf->name,
+							   target->content,
+							   size, size,
+							   &target->closure);
+		cr = cairo_create (surface);
+		perf->setup (cr, size, size);
+		perf->run (cr, size, size);
+	    }
+	}
+    }
+
+    return 0;
+}
+
diff --git a/perf/cairo-perf.h b/perf/cairo-perf.h
new file mode 100644
index 0000000..b5d9b7e
--- /dev/null
+++ b/perf/cairo-perf.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright © 2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#ifndef _CAIRO_PERF_H_
+#define _CAIRO_PERF_H_
+
+#include "cairo-boilerplate.h"
+
+extern unsigned int iterations;
+
+typedef void (*cairo_perf_func_t) (cairo_t *cr, int width, int height);
+
+#define DECL_PERF_FUNC(func) void func (cairo_t *cr, int width, int height)
+
+DECL_PERF_FUNC (paint_setup);
+DECL_PERF_FUNC (paint_alpha_setup);
+DECL_PERF_FUNC (paint);
+
+/* XXX: Obviously bogus as we bring up the infrastructure. */
+#define PERF_LOOP_INIT do {
+#define PERF_LOOP_FINI } while (0);
+
+#endif
diff --git a/perf/paint.c b/perf/paint.c
new file mode 100644
index 0000000..5c00e5c
--- /dev/null
+++ b/perf/paint.c
@@ -0,0 +1,49 @@
+/*
+ * Copyright © 2006 Red Hat, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Red Hat, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Red Hat, Inc. makes no representations about the
+ * suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * RED HAT, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL RED HAT, INC. BE LIABLE FOR ANY SPECIAL,
+ * INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
+ * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Carl D. Worth <cworth at cworth.org>
+ */
+
+#include "cairo-perf.h"
+
+void
+paint_setup (cairo_t *cr, int width, int height)
+{
+    cairo_set_source_rgba (cr, 1.0, 0.2, 0.6, 0.5);
+}
+
+void
+paint_alpha_setup (cairo_t *cr, int width, int height)
+{
+    cairo_set_source_rgb (cr, 0.2, 0.6, 0.9);
+}
+
+void
+paint (cairo_t *cr, int width, int height)
+{
+    PERF_LOOP_INIT;
+    {
+	cairo_paint (cr);
+	iterations++;
+    }
+    PERF_LOOP_FINI;
+}


More information about the cairo-commit mailing list