Revision: 48409
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48409
Author:   nazgul
Date:     2012-06-29 14:32:25 +0000 (Fri, 29 Jun 2012)
Log Message:
-----------
Added command line option "--debug-jobs"

This option enables time profiling of background jobs, namely it's
measuring run time of the job and prints it to the console.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_global.h
    trunk/blender/source/blender/windowmanager/intern/wm_jobs.c
    trunk/blender/source/creator/creator.c

Modified: trunk/blender/source/blender/blenkernel/BKE_global.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_global.h        2012-06-29 
13:55:25 UTC (rev 48408)
+++ trunk/blender/source/blender/blenkernel/BKE_global.h        2012-06-29 
14:32:25 UTC (rev 48409)
@@ -119,7 +119,8 @@
        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)

Modified: trunk/blender/source/blender/windowmanager/intern/wm_jobs.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_jobs.c 2012-06-29 
13:55:25 UTC (rev 48408)
+++ trunk/blender/source/blender/windowmanager/intern/wm_jobs.c 2012-06-29 
14:32:25 UTC (rev 48409)
@@ -54,8 +54,8 @@
 #include "wm_event_types.h"
 #include "wm.h"
 
+#include "PIL_time.h"
 
-
 /* ********************** Threaded Jobs Manager ****************************** 
*/
 
 /*
@@ -127,6 +127,7 @@
        /* we use BLI_threads api, but per job only 1 thread runs */
        ListBase threads;
 
+       double start_time;
 };
 
 /* finds:
@@ -343,6 +344,9 @@
                        /* 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 @@
                                        // 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);
                                        

Modified: trunk/blender/source/creator/creator.c
===================================================================
--- trunk/blender/source/creator/creator.c      2012-06-29 13:55:25 UTC (rev 
48408)
+++ trunk/blender/source/creator/creator.c      2012-06-29 14:32:25 UTC (rev 
48409)
@@ -1144,6 +1144,7 @@
 #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);
 

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to