diff piecrust/chefutil.py @ 415:0e9a94b7fdfa

bake: Improve bake record information. * Store things in the bake record that require less interaction between the master process and the workers. For instance, don't store the paginator object in the render pass info -- instead, just store whether pagination was used, and whether it had more items. * Simplify information passing between workers and bake passes by saving the rendering info to the JSON cache. This means the "render first sub" job doesn't have to return anything except errors now. * Add more performance counter info.
author Ludovic Chabant <ludovic@chabant.com>
date Sat, 20 Jun 2015 19:23:16 -0700
parents e7b865f8f335
children
line wrap: on
line diff
--- a/piecrust/chefutil.py	Sat Jun 20 19:20:30 2015 -0700
+++ b/piecrust/chefutil.py	Sat Jun 20 19:23:16 2015 -0700
@@ -5,10 +5,13 @@
 
 
 @contextlib.contextmanager
-def format_timed_scope(logger, message, *, level=logging.INFO, colored=True):
+def format_timed_scope(logger, message, *, level=logging.INFO, colored=True,
+                       timer_env=None, timer_category=None):
     start_time = time.perf_counter()
     yield
     logger.log(level, format_timed(start_time, message, colored=colored))
+    if timer_env is not None and timer_category is not None:
+        timer_env.stepTimer(timer_category, time.perf_counter() - start_time)
 
 
 def format_timed(start_time, message, indent_level=0, colored=True):