Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright OpenEmbedded Contributors |
| 3 | # |
| 4 | # SPDX-License-Identifier: MIT |
| 5 | # |
| 6 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | # Summarize sstate usage at the end of the build |
| 8 | python buildstats_summary () { |
| 9 | import collections |
| 10 | import os.path |
| 11 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 12 | bsdir = e.data.expand("${BUILDSTATS_BASE}/${BUILDNAME}") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 13 | if not os.path.exists(bsdir): |
| 14 | return |
| 15 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 16 | sstatetasks = (e.data.getVar('SSTATETASKS') or '').split() |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | 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 Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 39 | 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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 44 | } |
| 45 | addhandler buildstats_summary |
| 46 | buildstats_summary[eventmask] = "bb.event.BuildCompleted" |