Mercurial > piecrust2
diff piecrust/baking/baker.py @ 687:61d606fbc313
bake: Change `show-timers` to `show-stats`, add stats.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 14 Mar 2016 08:26:14 -0700 |
parents | 81d9c3a3a0b5 |
children | 9ae9390192da |
line wrap: on
line diff
--- a/piecrust/baking/baker.py Sun Mar 13 16:55:12 2016 -0700 +++ b/piecrust/baking/baker.py Mon Mar 14 08:26:14 2016 -0700 @@ -9,6 +9,7 @@ JOB_LOAD, JOB_RENDER_FIRST, JOB_BAKE) from piecrust.chefutil import ( format_timed_scope, format_timed) +from piecrust.environment import ExecutionStats from piecrust.routing import create_route_metadata from piecrust.sources.base import ( REALM_NAMES, REALM_USER, REALM_THEME) @@ -103,20 +104,16 @@ # Bake taxonomies. self._bakeTaxonomies(record, pool) - # All done with the workers. Close the pool and get timing reports. + # All done with the workers. Close the pool and get reports. reports = pool.close() - record.current.timers = {} + total_stats = ExecutionStats() + record.current.stats['_Total'] = total_stats for i in range(len(reports)): - timers = reports[i] - if timers is None: - continue - - worker_name = 'BakeWorker_%d' % i - record.current.timers[worker_name] = {} - for name, val in timers['data'].items(): - main_val = record.current.timers.setdefault(name, 0) - record.current.timers[name] = main_val + val - record.current.timers[worker_name][name] = val + worker_stats = reports[i]['data'] + if worker_stats is not None: + worker_name = 'BakeWorker_%d' % i + record.current.stats[worker_name] = worker_stats + total_stats.mergeStats(worker_stats) # Delete files from the output. self._handleDeletetions(record)