changeset 900:bf65a1a6992a

bake: Add performance timers for pipeline jobs.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 23 Jul 2017 08:21:07 -0700
parents e52e2dd08c96
children 1d5f02778723
files piecrust/baking/worker.py
diffstat 1 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/piecrust/baking/worker.py	Sun Jul 23 08:20:25 2017 -0700
+++ b/piecrust/baking/worker.py	Sun Jul 23 08:21:07 2017 -0700
@@ -44,6 +44,7 @@
         stats = app.env.stats
         stats.registerTimer("BakeWorker_%d_Total" % self.wid)
         stats.registerTimer("BakeWorkerInit")
+        self.timerScope = stats.timerScope
 
         self.app = app
 
@@ -71,6 +72,9 @@
 
             self.ppmngr.createPipeline(src)
 
+            stats.registerTimer("PipelineJobs_%s" % pname,
+                                raise_if_registered=False)
+
         stats.stepTimerSince("BakeWorkerInit", self._work_start_time)
 
     def process(self, job):
@@ -80,16 +84,19 @@
         ppinfo = self.ppmngr.getPipeline(job.source_name)
         pp = ppinfo.pipeline
 
-        runctx = PipelineJobRunContext(job, pp.record_name,
-                                       self.record_histories)
+        with self.timerScope("PipelineJobs_%s" % pp.PIPELINE_NAME):
+            runctx = PipelineJobRunContext(job, pp.record_name,
+                                           self.record_histories)
 
-        ppres = PipelineJobResult()
-        # For subsequent pass jobs, there will be a record entry given. For
-        # first pass jobs, there's none so we get the pipeline to create it.
-        ppres.record_entry = job.data.get('record_entry')
-        if ppres.record_entry is None:
-            ppres.record_entry = pp.createRecordEntry(job, runctx)
-        pp.run(job, runctx, ppres)
+            ppres = PipelineJobResult()
+            # For subsequent pass jobs, there will be a record entry given.
+            # For first pass jobs, there's none so we get the pipeline to
+            # create it.
+            ppres.record_entry = job.data.get('record_entry')
+            if ppres.record_entry is None:
+                ppres.record_entry = pp.createRecordEntry(job, runctx)
+            pp.run(job, runctx, ppres)
+
         return ppres
 
     def getStats(self):