[gegl] perf: Test gegl:scale-ratio performance



commit 1236c30a3e2158139ed909e6164c18663a5ee591
Author: Debarshi Ray <debarshir gnome org>
Date:   Mon Dec 28 10:22:37 2015 +0100

    perf: Test gegl:scale-ratio performance
    
    https://bugzilla.gnome.org/show_bug.cgi?id=759923

 perf/Makefile.am  |    2 +
 perf/test-scale.c |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/perf/Makefile.am b/perf/Makefile.am
index 9106d63..61db25e 100644
--- a/perf/Makefile.am
+++ b/perf/Makefile.am
@@ -8,6 +8,7 @@ noinst_PROGRAMS = \
        test-gegl-buffer-access \
        test-samplers \
        test-rotate \
+       test-scale \
        test-translate
 
 AM_CPPFLAGS = \
@@ -35,6 +36,7 @@ check:
        for a in $(noinst_PROGRAMS);do GEGL_PATH=../operations ./$$a;done;true
 
 test_rotate_SOURCES = test-rotate.c
+test_scale_SOURCES = test-scale.c
 test_translate_SOURCES = test-translate.c
 test_blur_SOURCES = test-blur.c
 test_bcontrast_SOURCES = test-bcontrast.c
diff --git a/perf/test-scale.c b/perf/test-scale.c
new file mode 100644
index 0000000..f326730
--- /dev/null
+++ b/perf/test-scale.c
@@ -0,0 +1,58 @@
+#include "test-common.h"
+
+void scale(GeglBuffer *buffer);
+void scale_nearest(GeglBuffer *buffer);
+
+gint
+main (gint    argc,
+      gchar **argv)
+{
+  GeglBuffer *buffer;
+
+  gegl_init (&argc, &argv);
+
+  buffer = test_buffer (1024, 1024, babl_format ("RGBA float"));
+  bench ("scale", buffer, &scale);
+  bench ("scale-nearest", buffer, &scale_nearest);
+  g_object_unref (buffer);
+
+  gegl_exit ();
+  return 0;
+}
+
+void scale(GeglBuffer *buffer)
+{
+  GeglBuffer *buffer2;
+  GeglNode   *gegl, *source, *scale, *sink;
+
+  gegl = gegl_node_new ();
+  source = gegl_node_new_child (gegl, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
+  scale = gegl_node_new_child (gegl, "operation", "gegl:scale-ratio", "x", 0.4, "y", 0.4, NULL);
+  sink = gegl_node_new_child (gegl, "operation", "gegl:buffer-sink", "buffer", &buffer2, NULL);
+
+  gegl_node_link_many (source, scale, sink, NULL);
+  gegl_node_process (sink);
+  g_object_unref (gegl);
+  g_object_unref (buffer2);
+}
+
+void scale_nearest(GeglBuffer *buffer)
+{
+  GeglBuffer *buffer2;
+  GeglNode   *gegl, *source, *scale, *sink;
+
+  gegl = gegl_node_new ();
+  source = gegl_node_new_child (gegl, "operation", "gegl:buffer-source", "buffer", buffer, NULL);
+  scale = gegl_node_new_child (gegl,
+                               "operation", "gegl:scale-ratio",
+                               "x", 0.4,
+                               "y", 0.4,
+                               "sampler", GEGL_SAMPLER_NEAREST,
+                               NULL);
+  sink = gegl_node_new_child (gegl, "operation", "gegl:buffer-sink", "buffer", &buffer2, NULL);
+
+  gegl_node_link_many (source, scale, sink, NULL);
+  gegl_node_process (sink);
+  g_object_unref (gegl);
+  g_object_unref (buffer2);
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]