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-25 09:55:36 +0000 |
commit | ba6caa021fea2edc5483bcde6d71122f2a2a871a (patch) | |
tree | 5f718c0ad2630c88471cdcaf16c8056d9b0ded73 /meta/classes | |
parent | bdbc158b474e23c3b736d58e5312a3b2209aba6e (diff) | |
download | poky-ba6caa021fea2edc5483bcde6d71122f2a2a871a.tar.gz |
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.
(From OE-Core rev: 406acd647a288694c2f776a9faa1f5607f3e8e7a)
Signed-off-by: Marius Avram <marius.avram@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-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): | |||
109 | diskdata["End"+key] = str(int(newdiskdata[key])) | 109 | diskdata["End"+key] = str(int(newdiskdata[key])) |
110 | return diskdata | 110 | return diskdata |
111 | 111 | ||
112 | def set_timedata(var, data): | 112 | def set_timedata(var, data, server_time=None): |
113 | import time | 113 | import time |
114 | time = time.time() | 114 | if server_time: |
115 | time = server_time | ||
116 | else: | ||
117 | time = time.time() | ||
115 | cputime = get_cputime() | 118 | cputime = get_cputime() |
116 | proctime = get_process_cputime(os.getpid()) | 119 | proctime = get_process_cputime(os.getpid()) |
117 | data.setVar(var, (time, cputime, proctime)) | 120 | data.setVar(var, (time, cputime, proctime)) |
118 | 121 | ||
119 | def get_timedata(var, data): | 122 | def get_timedata(var, data, server_time=None): |
120 | import time | 123 | import time |
121 | timedata = data.getVar(var, False) | 124 | timedata = data.getVar(var, False) |
122 | if timedata is None: | 125 | if timedata is None: |
@@ -124,7 +127,11 @@ def get_timedata(var, data): | |||
124 | oldtime, oldcpu, oldproc = timedata | 127 | oldtime, oldcpu, oldproc = timedata |
125 | procdiff = get_process_cputime(os.getpid()) - oldproc | 128 | procdiff = get_process_cputime(os.getpid()) - oldproc |
126 | cpudiff = get_cputime() - oldcpu | 129 | cpudiff = get_cputime() - oldcpu |
127 | timediff = time.time() - oldtime | 130 | if server_time: |
131 | end_time = server_time | ||
132 | else: | ||
133 | end_time = time.time() | ||
134 | timediff = end_time - oldtime | ||
128 | if cpudiff > 0: | 135 | if cpudiff > 0: |
129 | cpuperc = float(procdiff) * 100 / cpudiff | 136 | cpuperc = float(procdiff) * 100 / cpudiff |
130 | else: | 137 | else: |
@@ -136,7 +143,7 @@ def write_task_data(status, logfile, dev, e): | |||
136 | bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn) | 143 | bsdir = os.path.join(e.data.getVar('BUILDSTATS_BASE', True), bn) |
137 | taskdir = os.path.join(bsdir, e.data.expand("${PF}")) | 144 | taskdir = os.path.join(bsdir, e.data.expand("${PF}")) |
138 | file = open(os.path.join(logfile), "a") | 145 | file = open(os.path.join(logfile), "a") |
139 | timedata = get_timedata("__timedata_task", e.data) | 146 | timedata = get_timedata("__timedata_task", e.data, e.time) |
140 | if timedata: | 147 | if timedata: |
141 | elapsedtime, cpu = timedata | 148 | elapsedtime, cpu = timedata |
142 | file.write(bb.data.expand("${PF}: %s: Elapsed time: %0.2f seconds \n" % | 149 | 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): | |||
160 | file.write("Status: PASSED \n") | 167 | file.write("Status: PASSED \n") |
161 | else: | 168 | else: |
162 | file.write("Status: FAILED \n") | 169 | file.write("Status: FAILED \n") |
163 | file.write("Ended: %0.2f \n" % time.time()) | 170 | file.write("Ended: %0.2f \n" % e.time) |
164 | file.close() | 171 | file.close() |
165 | 172 | ||
166 | python run_buildstats () { | 173 | python run_buildstats () { |
@@ -234,7 +241,7 @@ python run_buildstats () { | |||
234 | taskdir = os.path.join(bsdir, e.data.expand("${PF}")) | 241 | taskdir = os.path.join(bsdir, e.data.expand("${PF}")) |
235 | if device != "NoLogicalDevice": | 242 | if device != "NoLogicalDevice": |
236 | set_diskdata("__diskdata_task", device, e.data) | 243 | set_diskdata("__diskdata_task", device, e.data) |
237 | set_timedata("__timedata_task", e.data) | 244 | set_timedata("__timedata_task", e.data, e.time) |
238 | try: | 245 | try: |
239 | bb.utils.mkdirhier(taskdir) | 246 | bb.utils.mkdirhier(taskdir) |
240 | except: | 247 | except: |
@@ -242,7 +249,7 @@ python run_buildstats () { | |||
242 | # write into the task event file the name and start time | 249 | # write into the task event file the name and start time |
243 | file = open(os.path.join(taskdir, e.task), "a") | 250 | file = open(os.path.join(taskdir, e.task), "a") |
244 | file.write("Event: %s \n" % bb.event.getName(e)) | 251 | file.write("Event: %s \n" % bb.event.getName(e)) |
245 | file.write("Started: %0.2f \n" % time.time()) | 252 | file.write("Started: %0.2f \n" % e.time) |
246 | file.close() | 253 | file.close() |
247 | 254 | ||
248 | elif isinstance(e, bb.build.TaskSucceeded): | 255 | elif isinstance(e, bb.build.TaskSucceeded): |