blob: 12e8f17836731eaf76372aa88944cd88c04da986 [file] [log] [blame]
Patrick Williams92b42cb2022-09-03 06:53:57 -05001#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
Patrick Williamsc124f4f2015-09-15 14:41:29 -05007# Summarize sstate usage at the end of the build
8python buildstats_summary () {
9 import collections
10 import os.path
11
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050012 bsdir = e.data.expand("${BUILDSTATS_BASE}/${BUILDNAME}")
Patrick Williamsc124f4f2015-09-15 14:41:29 -050013 if not os.path.exists(bsdir):
14 return
15
Brad Bishop6e60e8b2018-02-01 10:27:11 -050016 sstatetasks = (e.data.getVar('SSTATETASKS') or '').split()
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017 built = collections.defaultdict(lambda: [set(), set()])
18 for pf in os.listdir(bsdir):
19 taskdir = os.path.join(bsdir, pf)
20 if not os.path.isdir(taskdir):
21 continue
22
23 tasks = os.listdir(taskdir)
24 for t in sstatetasks:
25 no_sstate, sstate = built[t]
26 if t in tasks:
27 no_sstate.add(pf)
28 elif t + '_setscene' in tasks:
29 sstate.add(pf)
30
31 header_printed = False
32 for t in sstatetasks:
33 no_sstate, sstate = built[t]
34 if no_sstate | sstate:
35 if not header_printed:
36 header_printed = True
37 bb.note("Build completion summary:")
38
Patrick Williamsc0f7c042017-02-23 20:41:17 -060039 sstate_count = len(sstate)
40 no_sstate_count = len(no_sstate)
41 total_count = sstate_count + no_sstate_count
42 bb.note(" {0}: {1:.1f}% sstate reuse({2} setscene, {3} scratch)".format(
43 t, round(100 * sstate_count / total_count, 1), sstate_count, no_sstate_count))
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044}
45addhandler buildstats_summary
46buildstats_summary[eventmask] = "bb.event.BuildCompleted"