Added command line option "--debug-jobs"
authorSergey Sharybin <sergey.vfx@gmail.com>
Fri, 29 Jun 2012 14:32:25 +0000 (14:32 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Fri, 29 Jun 2012 14:32:25 +0000 (14:32 +0000)
This option enables time profiling of background jobs, namely it's
measuring run time of the job and prints it to the console.

source/blender/blenkernel/BKE_global.h
source/blender/windowmanager/intern/wm_jobs.c
source/creator/creator.c

index 593b4afb85c5f413d125ea0028f08d2d2d2eed3c..2d30844af80f3b72e603dc5683b679a0a213bf45 100644 (file)
@@ -119,7 +119,8 @@ enum {
        G_DEBUG_FFMPEG =    (1 << 1),
        G_DEBUG_PYTHON =    (1 << 2), /* extra python info */
        G_DEBUG_EVENTS =    (1 << 3), /* input/window/screen events */
-       G_DEBUG_WM =        (1 << 4)  /* operator, undo */
+       G_DEBUG_WM =        (1 << 4), /* operator, undo */
+       G_DEBUG_JOBS =      (1 << 5)  /* jobs time profiling */
 };
 
 #define G_DEBUG_ALL  (G_DEBUG | G_DEBUG_FFMPEG | G_DEBUG_PYTHON | G_DEBUG_EVENTS | G_DEBUG_WM)
index 73f59a5fbae110dc679b3642569e809721feaf7f..bd7b4694471525dfa498bcd58891de5a0aec8748 100644 (file)
@@ -54,7 +54,7 @@
 #include "wm_event_types.h"
 #include "wm.h"
 
-
+#include "PIL_time.h"
 
 /* ********************** Threaded Jobs Manager ****************************** */
 
@@ -127,6 +127,7 @@ struct wmJob {
        /* we use BLI_threads api, but per job only 1 thread runs */
        ListBase threads;
 
+       double start_time;
 };
 
 /* finds:
@@ -343,6 +344,9 @@ void WM_jobs_start(wmWindowManager *wm, wmJob *steve)
                        /* restarted job has timer already */
                        if (steve->wt == NULL)
                                steve->wt = WM_event_add_timer(wm, steve->win, TIMERJOBS, steve->timestep);
+
+                       if (G.debug & G_DEBUG_JOBS)
+                               steve->start_time = PIL_check_seconds_timer();
                }
                else printf("job fails, not initialized\n");
        }
@@ -465,6 +469,11 @@ void wm_jobs_timer(const bContext *C, wmWindowManager *wm, wmTimer *wt)
                                        // if (steve->stop) printf("job ready but stopped %s\n", steve->name);
                                        // else printf("job finished %s\n", steve->name);
 
+                                       if (G.debug & G_DEBUG_JOBS) {
+                                               printf("Job '%s' finished in %f seconds\n", steve->name,
+                                                      PIL_check_seconds_timer() - steve->start_time);
+                                       }
+
                                        steve->running = 0;
                                        BLI_end_threads(&steve->threads);
                                        
index 713c9220fd7cc4c9e38fc358db7a3e65fcab8abf..8c9cc45a050ef6a418ca5eced77a5a2329269370 100644 (file)
@@ -1144,6 +1144,7 @@ static void setupArguments(bContext *C, bArgs *ba, SYS_SystemHandle *syshandle)
 #endif
 
        BLI_argsAdd(ba, 1, NULL, "--debug-value", "<value>\n\tSet debug value of <value> on startup\n", set_debug_value, NULL);
+       BLI_argsAdd(ba, 1, NULL, "--debug-jobs",  "\n\tEnable time profiling for background jobs.", debug_mode_generic, (void *)G_DEBUG_JOBS);
 
        BLI_argsAdd(ba, 1, NULL, "--verbose", "<verbose>\n\tSet logging verbosity level.", set_verbosity, NULL);