From e69fc06d75d2d9a2ba2239791196dcc48801ab68 Mon Sep 17 00:00:00 2001 From: rbuj Date: Thu, 12 Nov 2020 13:30:05 +0100 Subject: test-eel-pixbuf-scale: Profile only the scaling functions just once --- test/test-eel-pixbuf-scale.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) (limited to 'test/test-eel-pixbuf-scale.c') diff --git a/test/test-eel-pixbuf-scale.c b/test/test-eel-pixbuf-scale.c index a46448b0..2aa10ecf 100644 --- a/test/test-eel-pixbuf-scale.c +++ b/test/test-eel-pixbuf-scale.c @@ -2,8 +2,6 @@ #include "test.h" -#define N_SCALES 100 - #define DEST_WIDTH 32 #define DEST_HEIGHT 32 @@ -13,7 +11,6 @@ main (int argc, char* argv[]) GdkPixbuf *pixbuf, *scaled; GError *error; gint64 t1, t2; - int i; test_init (&argc, &argv); @@ -35,34 +32,22 @@ main (int argc, char* argv[]) (double)gdk_pixbuf_get_height(pixbuf)/DEST_HEIGHT); t1 = g_get_monotonic_time (); - for (i = 0; i < N_SCALES; i++) { - scaled = eel_gdk_pixbuf_scale_down (pixbuf, DEST_WIDTH, DEST_HEIGHT); - g_object_unref (scaled); - } + scaled = eel_gdk_pixbuf_scale_down (pixbuf, DEST_WIDTH, DEST_HEIGHT); t2 = g_get_monotonic_time (); - g_print ("Time for eel_gdk_pixbuf_scale_down: %" G_GINT64_FORMAT " msecs\n", - (t2 - t1) / G_TIME_SPAN_MILLISECOND); - - + g_object_unref (scaled); + g_print ("Time for eel_gdk_pixbuf_scale_down: %" G_GINT64_FORMAT " usecs\n", t2 - t1); t1 = g_get_monotonic_time (); - for (i = 0; i < N_SCALES; i++) { - scaled = gdk_pixbuf_scale_simple (pixbuf, DEST_WIDTH, DEST_HEIGHT, GDK_INTERP_NEAREST); - g_object_unref (scaled); - } + scaled = gdk_pixbuf_scale_simple (pixbuf, DEST_WIDTH, DEST_HEIGHT, GDK_INTERP_NEAREST); t2 = g_get_monotonic_time (); - g_print ("Time for INTERP_NEAREST: %" G_GINT64_FORMAT " msecs\n", - (t2 - t1) / G_TIME_SPAN_MILLISECOND); - + g_object_unref (scaled); + g_print ("Time for INTERP_NEAREST: %" G_GINT64_FORMAT " usecs\n", t2 - t1); t1 = g_get_monotonic_time (); - for (i = 0; i < N_SCALES; i++) { - scaled = gdk_pixbuf_scale_simple (pixbuf, DEST_WIDTH, DEST_HEIGHT, GDK_INTERP_BILINEAR); - g_object_unref (scaled); - } + scaled = gdk_pixbuf_scale_simple (pixbuf, DEST_WIDTH, DEST_HEIGHT, GDK_INTERP_BILINEAR); t2 = g_get_monotonic_time (); - g_print ("Time for INTERP_BILINEAR: %" G_GINT64_FORMAT " msecs\n", - (t2 - t1) / G_TIME_SPAN_MILLISECOND); + g_object_unref (scaled); + g_print ("Time for INTERP_BILINEAR: %" G_GINT64_FORMAT " usecs\n", t2 - t1); scaled = eel_gdk_pixbuf_scale_down (pixbuf, DEST_WIDTH, DEST_HEIGHT); gdk_pixbuf_save (scaled, "eel_scaled.png", "png", NULL, NULL); -- cgit v1.2.1