Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Christopher Larson <kergoth@gmail.com>
To: openembedded-core@lists.openembedded.org
Subject: [PATCH v2] buildstats-summary.bbclass: Import useful bbclass from meta-mentor
Date: Fri, 13 Jun 2014 09:45:05 -0700	[thread overview]
Message-ID: <1402677905-15569-1-git-send-email-kergoth@gmail.com> (raw)
In-Reply-To: <1402082874-12187-1-git-send-email-Martin.Jansa@gmail.com>

From: Martin Jansa <martin.jansa@gmail.com>

This class summarizes sstate reuse at the end of the build, so you know how
much of your build was done from scratch.

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Signed-off-by: Christopher Larson <kergoth@gmail.com>
---
v2 changes: obey SSTATETASKS, add file comment -CL

 meta/classes/buildstats-summary.bbclass |   39 +++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 meta/classes/buildstats-summary.bbclass

diff --git a/meta/classes/buildstats-summary.bbclass b/meta/classes/buildstats-summary.bbclass
new file mode 100644
index 0000000..c8fbb2f
--- /dev/null
+++ b/meta/classes/buildstats-summary.bbclass
@@ -0,0 +1,39 @@
+# Summarize sstate usage at the end of the build
+python buildstats_summary () {
+    if not isinstance(e, bb.event.BuildCompleted):
+        return
+
+    import collections
+    import os.path
+
+    bn = get_bn(e)
+    bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn)
+    if not os.path.exists(bsdir):
+        return
+
+    sstatetasks = (e.data.getVar('SSTATETASKS', True) or '').split()
+    built = collections.defaultdict(lambda: [set(), set()])
+    for pf in os.listdir(bsdir):
+        taskdir = os.path.join(bsdir, pf)
+        if not os.path.isdir(taskdir):
+            continue
+
+        tasks = os.listdir(taskdir)
+        for t in sstatetasks:
+            no_sstate, sstate = built[t]
+            if t in tasks:
+                no_sstate.add(pf)
+            elif t + '_setscene' in tasks:
+                sstate.add(pf)
+
+    header_printed = False
+    for t in sstatetasks:
+        no_sstate, sstate = built[t]
+        if no_sstate | sstate:
+            if not header_printed:
+                header_printed = True
+                bb.note("Build completion summary:")
+
+            bb.note("  {0}: {1}% sstate reuse ({2} setscene, {3} scratch)".format(t, 100*len(sstate)/(len(sstate)+len(no_sstate)), len(sstate), len(no_sstate)))
+}
+addhandler buildstats_summary
-- 
1.7.9.5



      parent reply	other threads:[~2014-06-13 16:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-06 19:27 [PATCH] buildstats-summary.bbclass: Import useful bbclass from meta-mentor Martin Jansa
2014-06-11 20:54 ` Christopher Larson
2014-06-11 21:24   ` Martin Jansa
2014-06-13 16:45 ` Christopher Larson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1402677905-15569-1-git-send-email-kergoth@gmail.com \
    --to=kergoth@gmail.com \
    --cc=openembedded-core@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox