comparison 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
comparison
equal deleted inserted replaced
686:1a6c4c2683fd 687:61d606fbc313
7 from piecrust.baking.worker import ( 7 from piecrust.baking.worker import (
8 save_factory, 8 save_factory,
9 JOB_LOAD, JOB_RENDER_FIRST, JOB_BAKE) 9 JOB_LOAD, JOB_RENDER_FIRST, JOB_BAKE)
10 from piecrust.chefutil import ( 10 from piecrust.chefutil import (
11 format_timed_scope, format_timed) 11 format_timed_scope, format_timed)
12 from piecrust.environment import ExecutionStats
12 from piecrust.routing import create_route_metadata 13 from piecrust.routing import create_route_metadata
13 from piecrust.sources.base import ( 14 from piecrust.sources.base import (
14 REALM_NAMES, REALM_USER, REALM_THEME) 15 REALM_NAMES, REALM_USER, REALM_THEME)
15 16
16 17
101 self._bakeRealm(record, pool, realm, srclist) 102 self._bakeRealm(record, pool, realm, srclist)
102 103
103 # Bake taxonomies. 104 # Bake taxonomies.
104 self._bakeTaxonomies(record, pool) 105 self._bakeTaxonomies(record, pool)
105 106
106 # All done with the workers. Close the pool and get timing reports. 107 # All done with the workers. Close the pool and get reports.
107 reports = pool.close() 108 reports = pool.close()
108 record.current.timers = {} 109 total_stats = ExecutionStats()
110 record.current.stats['_Total'] = total_stats
109 for i in range(len(reports)): 111 for i in range(len(reports)):
110 timers = reports[i] 112 worker_stats = reports[i]['data']
111 if timers is None: 113 if worker_stats is not None:
112 continue 114 worker_name = 'BakeWorker_%d' % i
113 115 record.current.stats[worker_name] = worker_stats
114 worker_name = 'BakeWorker_%d' % i 116 total_stats.mergeStats(worker_stats)
115 record.current.timers[worker_name] = {}
116 for name, val in timers['data'].items():
117 main_val = record.current.timers.setdefault(name, 0)
118 record.current.timers[name] = main_val + val
119 record.current.timers[worker_name][name] = val
120 117
121 # Delete files from the output. 118 # Delete files from the output.
122 self._handleDeletetions(record) 119 self._handleDeletetions(record)
123 120
124 # Backup previous records. 121 # Backup previous records.