diff piecrust/baking/single.py @ 586:59268b4d8c71

bake: Add new performance timers.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 10 Jan 2016 10:51:11 -0800
parents 16e705c58cae
children 33ab9badfd7a
line wrap: on
line diff
--- a/piecrust/baking/single.py	Sat Jan 02 16:39:26 2016 -0800
+++ b/piecrust/baking/single.py	Sun Jan 10 10:51:11 2016 -0800
@@ -159,13 +159,15 @@
         if tax_info:
             ctx.setTaxonomyFilter(tax_info.term)
 
-        rp = render_page(ctx)
+        with self.app.env.timerScope("PageRender"):
+            rp = render_page(ctx)
 
-        out_dir = os.path.dirname(out_path)
-        _ensure_dir_exists(out_dir)
+        with self.app.env.timerScope("PageSerialize"):
+            out_dir = os.path.dirname(out_path)
+            _ensure_dir_exists(out_dir)
 
-        with codecs.open(out_path, 'w', 'utf8') as fp:
-            fp.write(rp.content)
+            with open(out_path, 'w', encoding='utf8') as fp:
+                fp.write(rp.content)
 
         return rp