From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core <openembedded-core@lists.openembedded.org>,
"Flanagan, Elizabeth" <elizabeth.flanagan@intel.com>
Subject: [PATCH 4/7] buildstats: Separate out the build and task data to allow improvements
Date: Thu, 17 Dec 2015 14:54:14 +0000 [thread overview]
Message-ID: <1450364054.13505.208.camel@linuxfoundation.org> (raw)
The combined build and task data code makes changing things hard, separate
out the functions so that changes can be made to the task data whilst the
build data remains unchanged.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 4fa6981..71469e4 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -20,17 +20,33 @@ def get_cputime():
fields = f.readline().rstrip().split()[1:]
return sum(int(field) for field in fields)
-def set_timedata(var, d, server_time=None):
- import time
- if server_time:
- time = server_time
+def set_timedata(var, d, server_time):
+ cputime = get_cputime()
+ proctime = get_process_cputime(os.getpid())
+ d.setVar(var, (server_time, cputime, proctime))
+
+def get_timedata(var, d, end_time):
+ timedata = d.getVar(var, False)
+ if timedata is None:
+ return
+ oldtime, oldcpu, oldproc = timedata
+ procdiff = get_process_cputime(os.getpid()) - oldproc
+ cpudiff = get_cputime() - oldcpu
+ timediff = end_time - oldtime
+ if cpudiff > 0:
+ cpuperc = float(procdiff) * 100 / cpudiff
else:
- time = time.time()
+ cpuperc = None
+ return timediff, cpuperc
+
+def set_buildtimedata(var, d):
+ import time
+ time = time.time()
cputime = get_cputime()
proctime = get_process_cputime(os.getpid())
d.setVar(var, (time, cputime, proctime))
-def get_timedata(var, d, server_time=None):
+def get_buildtimedata(var, d):
import time
timedata = d.getVar(var, False)
if timedata is None:
@@ -38,10 +54,7 @@ def get_timedata(var, d, server_time=None):
oldtime, oldcpu, oldproc = timedata
procdiff = get_process_cputime(os.getpid()) - oldproc
cpudiff = get_cputime() - oldcpu
- if server_time:
- end_time = server_time
- else:
- end_time = time.time()
+ end_time = time.time()
timediff = end_time - oldtime
if cpudiff > 0:
cpuperc = float(procdiff) * 100 / cpudiff
@@ -81,7 +94,7 @@ python run_buildstats () {
# set the buildname
########################################################################
bb.utils.mkdirhier(bsdir)
- set_timedata("__timedata_build", d)
+ set_buildtimedata("__timedata_build", d)
build_time = os.path.join(bsdir, "build_stats")
# write start of build into build_time
with open(build_time, "a") as f:
@@ -99,7 +112,7 @@ python run_buildstats () {
########################################################################
# Write build statistics for the build
########################################################################
- timedata = get_timedata("__timedata_build", d)
+ timedata = get_buildtimedata("__timedata_build", d)
if timedata:
time, cpu = timedata
# write end of build and cpu used into build_time
reply other threads:[~2015-12-17 14:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1450364054.13505.208.camel@linuxfoundation.org \
--to=richard.purdie@linuxfoundation.org \
--cc=elizabeth.flanagan@intel.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