summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-17 14:54:14 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-18 12:18:19 +0000
commit3187647d892fb5cf50158b0ceacfd9b759f695cb (patch)
tree12e6dc177d3f690f5e6338614d1438d398b4c0e2 /meta
parent38a255386446ca25cd3f715060e5464724c20d90 (diff)
downloadpoky-3187647d892fb5cf50158b0ceacfd9b759f695cb.tar.gz
buildstats: Separate out the build and task data to allow improvements
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. (From OE-Core rev: c79cfce4f820f20346d0565df8df626832976e28) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/buildstats.bbclass37
1 files changed, 25 insertions, 12 deletions
diff --git a/meta/classes/buildstats.bbclass b/meta/classes/buildstats.bbclass
index 4fa6981dd6..71469e401d 100644
--- a/meta/classes/buildstats.bbclass
+++ b/meta/classes/buildstats.bbclass
@@ -20,17 +20,33 @@ def get_cputime():
20 fields = f.readline().rstrip().split()[1:] 20 fields = f.readline().rstrip().split()[1:]
21 return sum(int(field) for field in fields) 21 return sum(int(field) for field in fields)
22 22
23def set_timedata(var, d, server_time=None): 23def set_timedata(var, d, server_time):
24 import time 24 cputime = get_cputime()
25 if server_time: 25 proctime = get_process_cputime(os.getpid())
26 time = server_time 26 d.setVar(var, (server_time, cputime, proctime))
27
28def get_timedata(var, d, end_time):
29 timedata = d.getVar(var, False)
30 if timedata is None:
31 return
32 oldtime, oldcpu, oldproc = timedata
33 procdiff = get_process_cputime(os.getpid()) - oldproc
34 cpudiff = get_cputime() - oldcpu
35 timediff = end_time - oldtime
36 if cpudiff > 0:
37 cpuperc = float(procdiff) * 100 / cpudiff
27 else: 38 else:
28 time = time.time() 39 cpuperc = None
40 return timediff, cpuperc
41
42def set_buildtimedata(var, d):
43 import time
44 time = time.time()
29 cputime = get_cputime() 45 cputime = get_cputime()
30 proctime = get_process_cputime(os.getpid()) 46 proctime = get_process_cputime(os.getpid())
31 d.setVar(var, (time, cputime, proctime)) 47 d.setVar(var, (time, cputime, proctime))
32 48
33def get_timedata(var, d, server_time=None): 49def get_buildtimedata(var, d):
34 import time 50 import time
35 timedata = d.getVar(var, False) 51 timedata = d.getVar(var, False)
36 if timedata is None: 52 if timedata is None:
@@ -38,10 +54,7 @@ def get_timedata(var, d, server_time=None):
38 oldtime, oldcpu, oldproc = timedata 54 oldtime, oldcpu, oldproc = timedata
39 procdiff = get_process_cputime(os.getpid()) - oldproc 55 procdiff = get_process_cputime(os.getpid()) - oldproc
40 cpudiff = get_cputime() - oldcpu 56 cpudiff = get_cputime() - oldcpu
41 if server_time: 57 end_time = time.time()
42 end_time = server_time
43 else:
44 end_time = time.time()
45 timediff = end_time - oldtime 58 timediff = end_time - oldtime
46 if cpudiff > 0: 59 if cpudiff > 0:
47 cpuperc = float(procdiff) * 100 / cpudiff 60 cpuperc = float(procdiff) * 100 / cpudiff
@@ -81,7 +94,7 @@ python run_buildstats () {
81 # set the buildname 94 # set the buildname
82 ######################################################################## 95 ########################################################################
83 bb.utils.mkdirhier(bsdir) 96 bb.utils.mkdirhier(bsdir)
84 set_timedata("__timedata_build", d) 97 set_buildtimedata("__timedata_build", d)
85 build_time = os.path.join(bsdir, "build_stats") 98 build_time = os.path.join(bsdir, "build_stats")
86 # write start of build into build_time 99 # write start of build into build_time
87 with open(build_time, "a") as f: 100 with open(build_time, "a") as f:
@@ -99,7 +112,7 @@ python run_buildstats () {
99 ######################################################################## 112 ########################################################################
100 # Write build statistics for the build 113 # Write build statistics for the build
101 ######################################################################## 114 ########################################################################
102 timedata = get_timedata("__timedata_build", d) 115 timedata = get_buildtimedata("__timedata_build", d)
103 if timedata: 116 if timedata:
104 time, cpu = timedata 117 time, cpu = timedata
105 # write end of build and cpu used into build_time 118 # write end of build and cpu used into build_time