diff piecrust/baking/worker.py @ 421:4a43d7015b75

bake: Improve performance timers reports. Add timers per-worker, and separate bake and pipeline workers.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 20 Jun 2015 23:27:39 -0700
parents 0e9a94b7fdfa
children a8a12f97addf
line wrap: on
line diff
--- a/piecrust/baking/worker.py	Sat Jun 20 23:27:04 2015 -0700
+++ b/piecrust/baking/worker.py	Sat Jun 20 23:27:39 2015 -0700
@@ -52,7 +52,8 @@
         # Create the app local to this worker.
         app = PieCrust(self.ctx.root_dir, debug=self.ctx.debug)
         app.env.fs_cache_only_for_main_page = True
-        app.env.registerTimer("Worker_%d" % self.wid)
+        app.env.registerTimer("BakeWorker_%d_Total" % self.wid)
+        app.env.registerTimer("BakeWorkerInit")
         app.env.registerTimer("JobReceive")
 
         # Create the job handlers.
@@ -63,6 +64,8 @@
         for jt, jh in job_handlers.items():
             app.env.registerTimer(type(jh).__name__)
 
+        app.env.stepTimerSince("BakeWorkerInit", work_start_time)
+
         # Start working!
         aborted_with_exception = None
         while not self.ctx.abort_event.is_set():
@@ -91,8 +94,8 @@
             self.ctx.results.put_nowait({'type': 'error', 'messages': msgs})
 
         # Send our timers to the main process before exiting.
-        app.env.stepTimer("Worker_%d" % self.wid,
-                          time.perf_counter() - work_start_time)
+        app.env.stepTimerSince("BakeWorker_%d_Total" % self.wid,
+                               work_start_time)
         self.ctx.results.put_nowait({
                 'type': 'timers', 'data': app.env._timers})
 
@@ -187,6 +190,9 @@
 
 
 class RenderFirstSubJobHandler(JobHandler):
+    def __init__(self, app, ctx):
+        super(RenderFirstSubJobHandler, self).__init__(app, ctx)
+
     def handleJob(self, job):
         # Render the segments for the first sub-page of this page.
         fac = job.payload.factory_info.build(self.app)