[gtk+] Add performance test for gtkcairoblur
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add performance test for gtkcairoblur
- Date: Sat, 21 Mar 2015 20:49:47 +0000 (UTC)
commit 9ba185b749542618bc2843517d49dc05ed006164
Author: Alexander Larsson <alexl redhat com>
Date: Thu Mar 19 16:24:19 2015 +0100
Add performance test for gtkcairoblur
This just creates a large cairo surface and times bluring it
at various values of radius.
https://bugzilla.gnome.org/show_bug.cgi?id=746468
tests/Makefile.am | 6 +++++
tests/blur-performance.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c94448c..c3bda57 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -34,6 +34,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
animated-revealing \
motion-compression \
scrolling-performance \
+ blur-performance \
simple \
flicker \
print-editor \
@@ -187,6 +188,7 @@ animated_revealing_DEPENDENCIES = $(TEST_DEPS)
flicker_DEPENDENCIES = $(TEST_DEPS)
motion_compression_DEPENDENCIES = $(TEST_DEPS)
scrolling_performance_DEPENDENCIES = $(TEST_DEPS)
+blur_performance_DEPENDENCIES = $(TEST_DEPS)
simple_DEPENDENCIES = $(TEST_DEPS)
print_editor_DEPENDENCIES = $(TEST_DEPS)
video_timer_DEPENDENCIES = $(TEST_DEPS)
@@ -318,6 +320,10 @@ scrolling_performance_SOURCES = \
variable.c \
variable.h
+blur_performance_SOURCES = \
+ blur-performance.c \
+ ../gtk/gtkcairoblur.c
+
video_timer_SOURCES = \
video-timer.c \
variable.c \
diff --git a/tests/blur-performance.c b/tests/blur-performance.c
new file mode 100644
index 0000000..c4381f9
--- /dev/null
+++ b/tests/blur-performance.c
@@ -0,0 +1,54 @@
+/* -*- mode: C; c-basic-offset: 2; indent-tabs-mode: nil; -*- */
+
+#include <gtk/gtkcairoblurprivate.h>
+
+static void
+init_surface (cairo_t *cr)
+{
+ int w = cairo_image_surface_get_width (cairo_get_target (cr));
+ int h = cairo_image_surface_get_height (cairo_get_target (cr));
+
+ cairo_set_source_rgb (cr, 0, 0, 0);
+ cairo_fill (cr);
+
+ cairo_set_source_rgb (cr, 1, 1, 1);
+ cairo_arc (cr, w/2, h/2, w/2, 0, 2*G_PI);
+ cairo_fill (cr);
+}
+
+int
+main (int argc, char **argv)
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+ GTimer *timer;
+ double msec;
+ int i, j;
+ int size;
+
+ timer = g_timer_new ();
+
+ size = 2000;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_A8, size, size);
+
+ cr = cairo_create (surface);
+
+ /* We do everything three times, first two as warmup */
+ for (j = 0; j < 2; j++)
+ {
+ for (i = 1; i < 16; i++)
+ {
+ init_surface (cr);
+ g_timer_start (timer);
+ _gtk_cairo_blur_surface (surface, i);
+ msec = g_timer_elapsed (timer, NULL) * 1000;
+ if (j == 1)
+ g_print ("Radius %2d: %.2f msec, %.2f kpixels/msec:\n", i, msec, size*size/(msec*1000));
+ }
+ }
+
+ g_timer_destroy (timer);
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]