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
|
#!/usr/bin/env python3
import sys, os
import matplotlib.pyplot as plot
xkcdstyle = 'XKCD_STYLE' in os.environ
if xkcdstyle:
plot.xkcd()
plot.figure()
multiple = 1
smultiple = ''
for path in sys.argv[1:]:
if path.startswith('*'):
multiple = float(path[1:])
smultiple = ' * ' + path[1:]
continue
with open(path, 'rb') as file:
lines = file.read()
lines = lines.decode('utf-8', 'strict').split('\n')
label, dim, xpoints, values = lines[0], int(lines[1]), lines[2], lines[3:]
label += smultiple
xpoints = [int(x) for x in xpoints.split(' ')]
xpoints[1] += 1
xpoints = list(range(*xpoints))
if dim == 3:
ypoints, values = values[0], values[1:]
ypoints = [int(x) for x in ypoints.split(' ')]
ypoints[1] += 1
ypoints = list(range(*ypoints))
values = [float(v) * multiple for v in values if v != '']
if dim == 2:
if 'PER_BIT' in os.environ:
values = [y / x for y, x in zip(values, xpoints)]
plot.plot(xpoints, values, label = label)
elif dim == 3:
pass
multiple = 1
smultiple = ''
if dim == 2:
plot.legend(loc = 'best')
plot.xlabel('bits')
plot.ylabel('time')
elif dim == 3:
pass
if not xkcdstyle:
plot.grid(True)
plot.show()
|