- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
Latest commit
executable file
·66 lines (58 loc) · 1.99 KB
/
Copy pathplot.py
File metadata and controls
executable file
·66 lines (58 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
importsys
fromsubprocessimportPopen, PIPE
fromcollectionsimportnamedtuple
fromStringIOimportStringIO
importtempfile
importos
Region=namedtuple('Region', 'title phases')
regions= [
Region('create-api', ['create:api']),
Region('pre-sched', ['create:none']),
Region('sched', ['create:scheduling']),
Region('netwk', ['create:networking']),
Region('bdmap', ['create:block_device_mapping']),
Region('spawn', ['create:spawning']),
Region('ovs-vsctl', ['syslog_ovsvsctl']),
Region('boot', ['console_boot']),
Region('iptables', ['iptables']),
Region('dhcp-host', ['syslog_dhcp']),
Region('dhcp-guest', ['console_dhcp']),
Region('pinging', ['ping']),
Region('sshing', ['ssh']),
Region('deleting', ['delete_api', 'delete']),
Region('deleted', ['fin']),
]
plot=StringIO()
plot.write('merge_cmd = "< ./merge-phases.py " . TITLE . ".phases ')
forregioninregions:
forphaseinregion.phases:
plot.write('%s '%phase)
plot.write('"\n')
plot.write('plot merge_cmd\\\n')
column_count=sum([len(r.phases) forrinregions])
foriinrange(len(regions)):
region=regions[len(regions) -i-1]
ifi>0:
plot.write(' ""\\\n')
plot.write(' using ($1):((')
plot.write(' + '.join(map(lambdac: '$%s'% (c+2), range(column_count))))
plot.write(') / N)\\\n')
plot.write(' title "%s" with boxes fs solid ls %d,\\\n'%
(region.title, i+1))
column_count-=len(region.phases)
plot.write(r''' cpu_cmd \
using ($3 - start_time):(utilization($6 * $7 * $8, $12))\
title 'U(CPU)' ls 100,\
dsk_cmd\
using ($3 - start_time):($8 / ($6 * 1000))\
title 'U(DSK)' ls 101
''')
script=tempfile.TemporaryFile()
script.write(open('plot.gpi').read())
script.write(plot.getvalue())
script.flush()
script_path='/proc/%d/fd/%d'% (os.getpid(), script.fileno())
p=Popen(['gnuplot', '-e', 'TITLE=\'%s\';'%sys.argv[1], script_path])
p.wait()
sys.exit(p.returncode)