buildstats-summary.bbclass 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #
  2. # Copyright OpenEmbedded Contributors
  3. #
  4. # SPDX-License-Identifier: MIT
  5. #
  6. # Summarize sstate usage at the end of the build
  7. python buildstats_summary () {
  8. import collections
  9. import os.path
  10. bsdir = e.data.expand("${BUILDSTATS_BASE}/${BUILDNAME}")
  11. if not os.path.exists(bsdir):
  12. return
  13. sstatetasks = (e.data.getVar('SSTATETASKS') or '').split()
  14. built = collections.defaultdict(lambda: [set(), set()])
  15. for pf in os.listdir(bsdir):
  16. taskdir = os.path.join(bsdir, pf)
  17. if not os.path.isdir(taskdir):
  18. continue
  19. tasks = os.listdir(taskdir)
  20. for t in sstatetasks:
  21. no_sstate, sstate = built[t]
  22. if t in tasks:
  23. no_sstate.add(pf)
  24. elif t + '_setscene' in tasks:
  25. sstate.add(pf)
  26. header_printed = False
  27. for t in sstatetasks:
  28. no_sstate, sstate = built[t]
  29. if no_sstate | sstate:
  30. if not header_printed:
  31. header_printed = True
  32. bb.note("Build completion summary:")
  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))
  38. }
  39. addhandler buildstats_summary
  40. buildstats_summary[eventmask] = "bb.event.BuildCompleted"