From 344ca17247accd2848081e69eab00ab7aac4a0ae Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 29 Jun 2012 14:32:25 +0000 Subject: 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. --- source/blender/windowmanager/intern/wm_jobs.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/windowmanager/intern/wm_jobs.c') diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 73f59a5fbae..bd7b4694471 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -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); -- cgit v1.2.3