# HG changeset patch # User Ludovic Chabant # Date 1500823545 25200 # Node ID cc26473600360fae800aeb6d796c67e6436d2d4a # Parent 812ca80863d4bf932ee9631cd827ced2be08724a internal: Remove unnecessary timer, add timer for lazy data building. diff -r 812ca80863d4 -r cc2647360036 piecrust/app.py --- a/piecrust/app.py Sun Jul 23 08:24:11 2017 -0700 +++ b/piecrust/app.py Sun Jul 23 08:25:45 2017 -0700 @@ -42,8 +42,8 @@ stats = env.stats stats.registerTimer('SiteConfigLoad') stats.registerTimer('PageLoad') - stats.registerTimer("PageDataBuild") stats.registerTimer("BuildRenderData") + stats.registerTimer("BuildLazyPageData") stats.registerTimer("PageRender") stats.registerTimer("PageRenderSegments") stats.registerTimer("PageRenderLayout") diff -r 812ca80863d4 -r cc2647360036 piecrust/data/pagedata.py --- a/piecrust/data/pagedata.py Sun Jul 23 08:24:11 2017 -0700 +++ b/piecrust/data/pagedata.py Sun Jul 23 08:25:45 2017 -0700 @@ -70,7 +70,8 @@ loader = self._loaders.get(name) if loader is not None: try: - self._values[name] = loader(self, name) + with self._page.app.env.stats.timerScope('BuildLazyPageData'): + self._values[name] = loader(self, name) except (LazyPageConfigLoaderHasNoValue, AbortedSourceUseError): raise except Exception as ex: @@ -90,7 +91,8 @@ loader = self._loaders.get('*') if loader is not None: try: - self._values[name] = loader(self, name) + with self._page.app.env.stats.timerScope('BuildLazyPageData'): + self._values[name] = loader(self, name) except (LazyPageConfigLoaderHasNoValue, AbortedSourceUseError): raise except Exception as ex: @@ -135,7 +137,8 @@ self._is_loaded = True try: - self._load() + with self._page.app.env.stats.timerScope('BuildLazyPageData'): + self._load() except Exception as ex: logger.exception(ex) raise Exception( diff -r 812ca80863d4 -r cc2647360036 piecrust/rendering.py --- a/piecrust/rendering.py Sun Jul 23 08:24:11 2017 -0700 +++ b/piecrust/rendering.py Sun Jul 23 08:25:45 2017 -0700 @@ -284,14 +284,13 @@ def _build_render_data(ctx): - with ctx.app.env.stats.timerScope("PageDataBuild"): - data_ctx = DataBuildingContext(ctx.page, ctx.sub_num) - data_ctx.pagination_source = ctx.pagination_source - data_ctx.pagination_filter = ctx.pagination_filter - page_data = build_page_data(data_ctx) - if ctx.custom_data: - page_data._appendMapping(ctx.custom_data) - return page_data + data_ctx = DataBuildingContext(ctx.page, ctx.sub_num) + data_ctx.pagination_source = ctx.pagination_source + data_ctx.pagination_filter = ctx.pagination_filter + page_data = build_page_data(data_ctx) + if ctx.custom_data: + page_data._appendMapping(ctx.custom_data) + return page_data def _do_render_page_segments_from_ctx(ctx):