diff options
author | Marius Avram <marius.avram@intel.com> | 2014-03-17 15:04:10 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-24 15:32:21 +0000 |
commit | 406acd647a288694c2f776a9faa1f5607f3e8e7a (patch) | |
tree | ea12c47c60b1893097633f54d1b6aed2fc3af037 | |
parent | 9e696b9d32e33ba37dc09ff312328e540fc25de2 (diff) | |
download | openembedded-core-406acd647a288694c2f776a9faa1f5607f3e8e7a.tar.gz openembedded-core-406acd647a288694c2f776a9faa1f5607f3e8e7a.tar.bz2 openembedded-core-406acd647a288694c2f776a9faa1f5607f3e8e7a.zip |
buildstats: use TaskBase time for elapsed time
To avoid any further inconsistencies between buildstats and buildinfohelper
from toaster, buildstats will measure task duration using the time field
from within the TaskBase events: TaskStarted and TaskSucceeded/TaskFailed.
Signed-off-by: Marius Avram <marius.avram@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/buildstats.bbclass | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass index 72fff1167f..89ae72c679 100644 --- a/meta/classes/buildstats.bbclass +++ b/meta/classes/buildstats.bbclass @@ -109,14 +109,17 @@ def get_diskdata(var, dev, data): diskdata["End"+key] = str(int(newdiskdata[key])) return diskdata -def set_timedata(var, data): +def set_timedata(var, data, server_time=None): import time - time = time.time() + if server_time: + time = server_time + else: + time = time.time() cputime = get_cputime() proctime = get_process_cputime(os.getpid()) data.setVar(var, (time, cputime, proctime)) -def get_timedata(var, data): +def get_timedata(var, data, server_time=None): import time timedata = data.getVar(var, False) if timedata is None: @@ -124,7 +127,11 @@ def get_timedata(var, data): oldtime, oldcpu, oldproc = timedata procdiff = get_process_cputime(os.getpid()) - oldproc cpudiff = get_cputime() - oldcpu - timediff = time.time() - oldtime + if server_time: + end_time = server_time + else: + end_time = time.time() + timediff = end_time - oldtime if cpudiff > 0: cpuperc = float(procdiff) * 100 / cpudiff else: @@ -136,7 +143,7 @@ def write_task_data(status, logfile, dev, e): bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn) taskdir = os.path.join(bsdir, e.data.expand("${PF}")) file = open(os.path.join(logfile), "a") - timedata = get_timedata("__timedata_task", e.data) + timedata = get_timedata("__timedata_task", e.data, e.time) if timedata: elapsedtime, cpu = timedata file.write(bb.data.expand("${PF}: %s: Elapsed time: %0.2f seconds \n" % @@ -160,7 +167,7 @@ def write_task_data(status, logfile, dev, e): file.write("Status: PASSED \n") else: file.write("Status: FAILED \n") - file.write("Ended: %0.2f \n" % time.time()) + file.write("Ended: %0.2f \n" % e.time) file.close() python run_buildstats () { @@ -234,7 +241,7 @@ python run_buildstats () { taskdir = os.path.join(bsdir, e.data.expand("${PF}")) if device != "NoLogicalDevice": set_diskdata("__diskdata_task", device, e.data) - set_timedata("__timedata_task", e.data) + set_timedata("__timedata_task", e.data, e.time) try: bb.utils.mkdirhier(taskdir) except: @@ -242,7 +249,7 @@ python run_buildstats () { # write into the task event file the name and start time file = open(os.path.join(taskdir, e.task), "a") file.write("Event: %s \n" % bb.event.getName(e)) - file.write("Started: %0.2f \n" % time.time()) + file.write("Started: %0.2f \n" % e.time) file.close() elif isinstance(e, bb.build.TaskSucceeded): |