gimp r25679 - in trunk: . app/core



Author: neo
Date: Fri May 16 21:01:24 2008
New Revision: 25679
URL: http://svn.gnome.org/viewvc/gimp?rev=25679&view=rev

Log:
2008-05-16  Sven Neumann  <sven gimp org>

	* app/core/gimpimagemap.c: added some basic benchmarking code.
	Will become optional but for now it is enabled by default.



Modified:
   trunk/ChangeLog
   trunk/app/core/gimpimagemap.c

Modified: trunk/app/core/gimpimagemap.c
==============================================================================
--- trunk/app/core/gimpimagemap.c	(original)
+++ trunk/app/core/gimpimagemap.c	Fri May 16 21:01:24 2008
@@ -80,6 +80,9 @@
   GeglProcessor         *processor;
 
   guint                  idle_id;
+
+  GTimer                *timer;
+  gulong                 pixel_count;
 };
 
 
@@ -152,6 +155,11 @@
   image_map->apply_data    = NULL;
   image_map->PRI           = NULL;
   image_map->idle_id       = 0;
+  image_map->timer         = g_timer_new ();
+  image_map->pixel_count   = 0;
+
+  if (image_map->timer)
+    g_timer_stop (image_map->timer);
 }
 
 static void
@@ -223,6 +231,12 @@
       image_map->drawable = NULL;
     }
 
+  if (image_map->timer)
+    {
+      g_timer_destroy (image_map->timer);
+      image_map->timer = NULL;
+    }
+
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
@@ -550,6 +564,12 @@
                                                &image_map->destPR);
     }
 
+  if (image_map->timer)
+    {
+      image_map->pixel_count = 0;
+      g_timer_reset (image_map->timer);
+    }
+
   /*  Start the intermittant work procedure  */
   image_map->idle_id = g_idle_add ((GSourceFunc) gimp_image_map_do, image_map);
 }
@@ -711,8 +731,25 @@
 
   if (image_map->gegl)
     {
-      if (! gegl_processor_work (image_map->processor, NULL))
+      gboolean pending;
+
+      if (image_map->timer)
+        g_timer_continue (image_map->timer);
+
+      pending = gegl_processor_work (image_map->processor, NULL);
+
+      if (image_map->timer)
+        g_timer_stop (image_map->timer);
+
+      if (! pending)
         {
+          if (image_map->timer)
+            g_printerr ("%s: %g MPixels/sec\n",
+                        image_map->undo_desc,
+                        (gdouble) image_map->pixel_count /
+                        (1000000.0 *
+                         g_timer_elapsed (image_map->timer, NULL)));
+
           g_object_unref (image_map->processor);
           image_map->processor = NULL;
 
@@ -737,6 +774,9 @@
           PixelRegion  destPR;
           gint         x, y, w, h;
 
+          if (image_map->timer)
+            g_timer_continue (image_map->timer);
+
           x = image_map->destPR.x;
           y = image_map->destPR.y;
           w = image_map->destPR.w;
@@ -771,8 +811,21 @@
 
           image_map->PRI = pixel_regions_process (image_map->PRI);
 
+          if (image_map->timer)
+            {
+              g_timer_stop (image_map->timer);
+              image_map->pixel_count += w * h;
+            }
+
           if (image_map->PRI == NULL)
             {
+              if (image_map->timer)
+                g_printerr ("%s: %g MPixels/sec\n",
+                            image_map->undo_desc,
+                            (gdouble) image_map->pixel_count /
+                            (1000000.0 *
+                             g_timer_elapsed (image_map->timer, NULL)));
+
               image_map->idle_id = 0;
 
               g_signal_emit (image_map, image_map_signals[FLUSH], 0);
@@ -833,4 +886,7 @@
   gimp_drawable_update (image_map->drawable,
                         extent->x, extent->y,
                         extent->width, extent->height);
+
+  if (image_map->timer)
+    image_map->pixel_count += extent->width * extent->height;
 }



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