[gimp/soc-2010-cage] app: add simple macros GIMP_TIMER_START() and GIMP_TIMER_END()
- From: Michael Muré <mmure src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/soc-2010-cage] app: add simple macros GIMP_TIMER_START() and GIMP_TIMER_END()
- Date: Wed, 30 Jun 2010 22:07:17 +0000 (UTC)
commit 5479a91cf5d5e93aea911c456aef6cd87546866d
Author: Michael Natterer <mitch gimp org>
Date: Sun Jun 6 20:24:27 2010 +0200
app: add simple macros GIMP_TIMER_START() and GIMP_TIMER_END()
which measure the time taken between them and print out a message.
Use it for projection benchmarking and add timing to scaling.
app/actions/debug-commands.c | 9 +++------
app/core/gimp-utils.h | 9 +++++++++
app/core/gimpdrawable.c | 5 +++++
3 files changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/app/actions/debug-commands.c b/app/actions/debug-commands.c
index 83e4811..8e05274 100644
--- a/app/actions/debug-commands.c
+++ b/app/actions/debug-commands.c
@@ -31,6 +31,7 @@
#include "base/tile.h"
#include "core/gimp.h"
+#include "core/gimp-utils.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
@@ -291,7 +292,6 @@ debug_benchmark_projection (GimpImage *image)
{
GimpProjection *projection = gimp_image_get_projection (image);
TileManager *tiles;
- GTimer *timer;
gint x, y;
gimp_image_invalidate (image,
@@ -302,7 +302,7 @@ debug_benchmark_projection (GimpImage *image)
tiles = gimp_pickable_get_tiles (GIMP_PICKABLE (projection));
- timer = g_timer_new ();
+ GIMP_TIMER_START ();
for (x = 0; x < tile_manager_width (tiles); x += TILE_WIDTH)
{
@@ -314,10 +314,7 @@ debug_benchmark_projection (GimpImage *image)
}
}
- g_print ("Validation of the entire projection took %.0f ms\n",
- 1000 * g_timer_elapsed (timer, NULL));
-
- g_timer_destroy (timer);
+ GIMP_TIMER_END ("Validation of the entire projection");
g_object_unref (image);
diff --git a/app/core/gimp-utils.h b/app/core/gimp-utils.h
index f916d1e..6c77140 100644
--- a/app/core/gimp-utils.h
+++ b/app/core/gimp-utils.h
@@ -19,6 +19,15 @@
#define __APP_GIMP_UTILS_H__
+#define GIMP_TIMER_START() \
+ { GTimer *_timer = g_timer_new ();
+
+#define GIMP_TIMER_END(message) \
+ g_printerr ("%s: " message " took %0.2f seconds\n", \
+ G_STRFUNC, g_timer_elapsed (_timer, NULL)); \
+ g_timer_destroy (_timer); }
+
+
gint64 gimp_g_type_instance_get_memsize (GTypeInstance *instance);
gint64 gimp_g_object_get_memsize (GObject *object);
gint64 gimp_g_hash_table_get_memsize (GHashTable *hash,
diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c
index 35db04c..9a770c2 100644
--- a/app/core/gimpdrawable.c
+++ b/app/core/gimpdrawable.c
@@ -36,6 +36,7 @@
#include "gegl/gimp-gegl-utils.h"
#include "gimp.h" /* temp for gimp_use_gegl() */
+#include "gimp-utils.h" /* temp for GIMP_TIMER */
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpdrawable-combine.h"
@@ -460,6 +461,8 @@ gimp_drawable_scale (GimpItem *item,
new_tiles = tile_manager_new (new_width, new_height, drawable->bytes);
+ GIMP_TIMER_START ();
+
if (gimp_use_gegl (gimp_item_get_image (item)->gimp) &&
! gimp_drawable_is_indexed (drawable) &&
interpolation_type != GIMP_INTERPOLATION_LANCZOS)
@@ -511,6 +514,8 @@ gimp_drawable_scale (GimpItem *item,
progress);
}
+ GIMP_TIMER_END ("scaling");
+
gimp_drawable_set_tiles_full (drawable, gimp_item_is_attached (item), NULL,
new_tiles, gimp_drawable_type (drawable),
new_offset_x, new_offset_y);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]