in debug mode print time information on selected events
authorVladimir Nadvornik <nadvornik@suse.cz>
Wed, 16 Apr 2008 20:15:42 +0000 (20:15 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Wed, 16 Apr 2008 20:15:42 +0000 (20:15 +0000)
src/image.c
src/main.c
src/main.h
src/pixbuf-renderer.c
src/pixbuf-renderer.h

index ab65bab..69e8def 100644 (file)
@@ -116,7 +116,7 @@ static void image_complete_util(ImageWindow *imd, gint preload)
 {
        if (imd->il && image_get_pixbuf(imd) != image_loader_get_pixbuf(imd->il)) return;
 
-       if (debug) printf("image load completed \"%s\" (%s)\n",
+       if (debug) printf("%s image load completed \"%s\" (%s)\n", get_exec_time(),
                          (preload) ? (imd->read_ahead_fd ? imd->read_ahead_fd->path : "null") : 
                                      (imd->image_fd ? imd->image_fd->path : "null"),
                          (preload) ? "preload" : "current");
@@ -289,6 +289,7 @@ static void image_alter_real(ImageWindow *imd, AlterType type, gint clamp)
 
        if (exif_rotate) image_state_set(imd, IMAGE_STATE_ROTATE_AUTO);
        layout_image_overlay_update(layout_find_by_image(imd));
+       if (debug) printf("%s image postprocess done: %s\n", get_exec_time(), imd->image_fd->name);
 }
 
 static void image_post_process_alter(ImageWindow *imd, gint clamp)
@@ -312,6 +313,7 @@ static void image_post_process_color_cb(ColorMan *cm, ColorManReturnType type, g
 
        imd->cm = NULL;
        image_state_set(imd, IMAGE_STATE_COLOR_ADJ);
+       if (debug) printf("%s image postprocess cm done: %s\n", get_exec_time(), imd->image_fd->name);
 
        image_post_process_alter(imd, FALSE);
 
@@ -427,6 +429,8 @@ static void image_post_process(ImageWindow *imd, gint clamp)
 
        if (!image_get_pixbuf(imd)) return;
 
+       if (debug) printf("%s image postprocess: %s\n", get_exec_time(), imd->image_fd->name);
+
        if (options->image.exif_rotate_enable ||
            (imd->color_profile_enable && imd->color_profile_use_image) )
                {
@@ -516,7 +520,7 @@ static void image_post_process(ImageWindow *imd, gint clamp)
 
 static void image_read_ahead_cancel(ImageWindow *imd)
 {
-       if (debug) printf("read ahead cancelled for :%s\n", imd->read_ahead_fd ? imd->read_ahead_fd->path : "null");
+       if (debug) printf("%s read ahead cancelled for :%s\n", get_exec_time(), imd->read_ahead_fd ? imd->read_ahead_fd->path : "null");
 
        image_loader_free(imd->read_ahead_il);
        imd->read_ahead_il = NULL;
@@ -532,7 +536,7 @@ static void image_read_ahead_done_cb(ImageLoader *il, gpointer data)
 {
        ImageWindow *imd = data;
 
-       if (debug) printf("read ahead done for :%s\n", imd->read_ahead_fd->path);
+       if (debug) printf("%s read ahead done for :%s\n", get_exec_time(), imd->read_ahead_fd->path);
 
        imd->read_ahead_pixbuf = image_loader_get_pixbuf(imd->read_ahead_il);
        if (imd->read_ahead_pixbuf)
@@ -563,7 +567,7 @@ static void image_read_ahead_start(ImageWindow *imd)
        /* still loading ?, do later */
        if (imd->il || imd->cm) return;
 
-       if (debug) printf("read ahead started for :%s\n", imd->read_ahead_fd->path);
+       if (debug) printf("%s read ahead started for :%s\n", get_exec_time(), imd->read_ahead_fd->path);
 
        imd->read_ahead_il = image_loader_new(imd->read_ahead_fd);
 
@@ -614,7 +618,7 @@ static void image_post_buffer_set(ImageWindow *imd, FileData *fd, GdkPixbuf *pix
                imd->prev_color_row = -1;
                }
 
-       if (debug) printf("post buffer set: %s\n", fd ? fd->path : "null");
+       if (debug) printf("%s post buffer set: %s\n", get_exec_time(), fd ? fd->path : "null");
 }
 
 static gint image_post_buffer_get(ImageWindow *imd)
@@ -684,7 +688,7 @@ static void image_load_done_cb(ImageLoader *il, gpointer data)
 {
        ImageWindow *imd = data;
 
-       if (debug) printf ("image done\n");
+       if (debug) printf ("%s image done\n", get_exec_time());
 
        g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL);
        image_state_unset(imd, IMAGE_STATE_LOADING);
@@ -706,7 +710,7 @@ static void image_load_done_cb(ImageLoader *il, gpointer data)
 
 static void image_load_error_cb(ImageLoader *il, gpointer data)
 {
-       if (debug) printf ("image error\n");
+       if (debug) printf ("%s image error\n", get_exec_time());
 
        /* even on error handle it like it was done,
         * since we have a pixbuf with _something_ */
@@ -787,7 +791,7 @@ static gint image_read_ahead_check(ImageWindow *imd)
 
 static gint image_load_begin(ImageWindow *imd, FileData *fd)
 {
-       if (debug) printf ("image begin \n");
+       if (debug) printf ("%s image begin \n", get_exec_time());
 
        if (imd->il) return FALSE;
 
@@ -852,7 +856,7 @@ static void image_reset(ImageWindow *imd)
 {
        /* stops anything currently being done */
 
-       if (debug) printf("image reset\n");
+       if (debug) printf("%s image reset\n", get_exec_time());
 
        g_object_set(G_OBJECT(imd->pr), "loading", FALSE, NULL);
 
index cec6d15..7681350 100644 (file)
@@ -117,6 +117,31 @@ gdouble get_zoom_increment(void)
        return ((options->image.zoom_increment != 0) ? (gdouble)options->image.zoom_increment / 10.0 : 1.0);
 }
 
+const gchar *get_exec_time()
+{
+       static timestr[20];
+       static struct timeval start_tv = {0, 0};
+       
+       struct timeval tv = {0, 0};
+       
+       gettimeofday(&tv, NULL);
+       
+       if (start_tv.tv_sec == 0) start_tv = tv;
+       
+       tv.tv_sec -= start_tv.tv_sec;
+       if (tv.tv_usec >= start_tv.tv_usec) 
+               tv.tv_usec -= start_tv.tv_usec;
+       else
+               {
+               tv.tv_usec += 1000000 - start_tv.tv_usec;
+               tv.tv_sec -= 1;
+               }
+       
+       g_snprintf(timestr, sizeof(timestr), "%5d.%06d", tv.tv_sec, tv.tv_usec);
+       
+       return timestr;
+}
+
 /*
  *-----------------------------------------------------------------------------
  * Open  browser with the help Documentation
@@ -1339,6 +1364,9 @@ int main (int argc, char *argv[])
        gchar *buf;
        gchar *bufl;
 
+       /* init execution time counter*/
+       get_exec_time();
+       
        /* setup locale, i18n */
        gtk_set_locale();
        bindtextdomain(PACKAGE, GQ_LOCALEDIR);
index f4da154..0ab3e0e 100644 (file)
@@ -137,6 +137,8 @@ gint window_maximized(GtkWidget *window);
 
 gdouble get_zoom_increment(void);
 
+const gchar *get_exec_time();
+
 void help_window_show(const gchar *key);
 
 void keyboard_scroll_calc(gint *x, gint *y, GdkEventKey *event);
index d6c4ed0..749d745 100644 (file)
@@ -27,6 +27,9 @@
 
 #ifdef GQ_BUILD
        #include "pixbuf_util.h"
+       
+       /* for debug */
+       #include "main.h"
 #endif
 
 
@@ -2497,6 +2500,8 @@ static void pr_update_signal(PixbufRenderer *pr)
 #if 0
        printf("FIXME: send updated signal\n");
 #endif
+       if (debug) printf("%s pixbuf renderer updated - started drawing %p\n", get_exec_time(), pr);
+       pr->debug_updated = TRUE;
 }
 
 static void pr_zoom_signal(PixbufRenderer *pr)
@@ -2521,6 +2526,11 @@ static void pr_render_complete_signal(PixbufRenderer *pr)
                g_signal_emit(pr, signals[SIGNAL_RENDER_COMPLETE], 0);
                g_object_set(G_OBJECT(pr), "complete", TRUE, NULL);
                }
+       if (pr->debug_updated)
+               {
+               if (debug) printf("%s pixbuf renderer done %p\n", get_exec_time(), pr);
+               pr->debug_updated = FALSE;
+               }
 }
 
 static void pr_drag_signal(PixbufRenderer *pr, GdkEventButton *bevent)
index 9e95c82..9c0f1c8 100644 (file)
@@ -125,6 +125,7 @@ struct _PixbufRenderer
        gboolean delay_flip;
        gboolean loading;
        gboolean complete;
+       gboolean debug_updated; /* debug only */
 
        gint scroller_id;
        gint scroller_overlay;