Mercurial > piecrust2
changeset 904:cc2647360036
internal: Remove unnecessary timer, add timer for lazy data building.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sun, 23 Jul 2017 08:25:45 -0700 |
parents | 812ca80863d4 |
children | 1d0364614665 |
files | piecrust/app.py piecrust/data/pagedata.py piecrust/rendering.py |
diffstat | 3 files changed, 14 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- 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")
--- 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(
--- 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):