10
def _get_dashboard_data(timing_file):
11
info = subprocess.check_output(['adb', 'shell', 'system-image-cli', '-i'])
14
'machine_mac': 'ff:ff:ff:ff:ff:ff',
15
'ran_at': datetime.datetime.now().isoformat(),
18
for line in info.split('\r\n'):
21
key, val = line.split(':', 1)
23
if key == 'device name':
24
data['image_arch'] = val
25
elif key == 'channel':
26
# get 'touch' and 'trusty' from something like:
27
# ubuntu-touch/trusty-proposed
28
variant, release = val.split('/')
29
data['image_variant'] = variant.split('-')[1]
30
data['image_release'] = release.split('-')[0]
31
elif key == 'version version':
33
elif key == 'version ubuntu':
34
data['version_ubuntu'] = val
35
elif key == 'version device':
36
data['version_device'] = val
37
data['build_number'] = '%s:%s:%s' % (
38
data['number'], data['version_ubuntu'], data['version_device'])
40
with open(timing_file) as f:
41
# the timings file is sequence of readings (in hundredths of a second):
42
# line 0 - the total boot time
43
# line X - the time from boot until the given annotation *started*
44
timings = [float(x) / 100.0 for x in f.read().split('\n') if x]
45
data['boot'] = timings[0]
46
data['kernel'] = timings[1]
47
data['plumbing'] = timings[2] - timings[1]
48
data['xorg'] = timings[3] - timings[2]
49
data['desktop'] = timings[0] - timings[3]
53
def chart(results_dir):
54
timings = os.path.join(results_dir, 'timings')
55
os.environ['CHARTOPTS'] = ' '.join([
56
'--crop-after=unity8',
57
'--annotate=mountall',
60
'--annotate-file=%s' % timings,
62
subprocess.check_call(['phablet-bootchart', '-n', '-k',
63
'-w', '/home/ubuntu/magners-wifi',
65
data = _get_dashboard_data(timings)
66
with open(os.path.join(results_dir, 'boot.json'), 'w') as f:
67
json.dump(data, f, indent=4)
69
if __name__ == '__main__':
70
if os.path.exists('/tmp/results'):
71
shutil.rmtree('/tmp/results')
72
os.mkdir('/tmp/results')
74
chart('/tmp/results/%d' % (x + 1))