buildstats-summary.bbclass 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Summarize sstate usage at the end of the build
  2. python buildstats_summary () {
  3. import collections
  4. import os.path
  5. bsdir = e.data.expand("${BUILDSTATS_BASE}/${BUILDNAME}")
  6. if not os.path.exists(bsdir):
  7. return
  8. sstatetasks = (e.data.getVar('SSTATETASKS') or '').split()
  9. built = collections.defaultdict(lambda: [set(), set()])
  10. for pf in os.listdir(bsdir):
  11. taskdir = os.path.join(bsdir, pf)
  12. if not os.path.isdir(taskdir):
  13. continue
  14. tasks = os.listdir(taskdir)
  15. for t in sstatetasks:
  16. no_sstate, sstate = built[t]
  17. if t in tasks:
  18. no_sstate.add(pf)
  19. elif t + '_setscene' in tasks:
  20. sstate.add(pf)
  21. header_printed = False
  22. for t in sstatetasks:
  23. no_sstate, sstate = built[t]
  24. if no_sstate | sstate:
  25. if not header_printed:
  26. header_printed = True
  27. bb.note("Build completion summary:")
  28. sstate_count = len(sstate)
  29. no_sstate_count = len(no_sstate)
  30. total_count = sstate_count + no_sstate_count
  31. bb.note(" {0}: {1:.1f}% sstate reuse({2} setscene, {3} scratch)".format(
  32. t, round(100 * sstate_count / total_count, 1), sstate_count, no_sstate_count))
  33. }
  34. addhandler buildstats_summary
  35. buildstats_summary[eventmask] = "bb.event.BuildCompleted"