Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | # Summarize sstate usage at the end of the build |
| 2 | python buildstats_summary () { |
| 3 | import collections |
| 4 | import os.path |
| 5 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 6 | bsdir = e.data.expand("${BUILDSTATS_BASE}/${BUILDNAME}") |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 7 | if not os.path.exists(bsdir): |
| 8 | return |
| 9 | |
| 10 | sstatetasks = (e.data.getVar('SSTATETASKS', True) or '').split() |
| 11 | built = collections.defaultdict(lambda: [set(), set()]) |
| 12 | for pf in os.listdir(bsdir): |
| 13 | taskdir = os.path.join(bsdir, pf) |
| 14 | if not os.path.isdir(taskdir): |
| 15 | continue |
| 16 | |
| 17 | tasks = os.listdir(taskdir) |
| 18 | for t in sstatetasks: |
| 19 | no_sstate, sstate = built[t] |
| 20 | if t in tasks: |
| 21 | no_sstate.add(pf) |
| 22 | elif t + '_setscene' in tasks: |
| 23 | sstate.add(pf) |
| 24 | |
| 25 | header_printed = False |
| 26 | for t in sstatetasks: |
| 27 | no_sstate, sstate = built[t] |
| 28 | if no_sstate | sstate: |
| 29 | if not header_printed: |
| 30 | header_printed = True |
| 31 | bb.note("Build completion summary:") |
| 32 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | sstate_count = len(sstate) |
| 34 | no_sstate_count = len(no_sstate) |
| 35 | total_count = sstate_count + no_sstate_count |
| 36 | bb.note(" {0}: {1:.1f}% sstate reuse({2} setscene, {3} scratch)".format( |
| 37 | 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] | 38 | } |
| 39 | addhandler buildstats_summary |
| 40 | buildstats_summary[eventmask] = "bb.event.BuildCompleted" |