blob: d5f68637e8df710fdff0b21a3c108605a2792e48 (
plain)
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
|
#!/usr/bin/python3
# generate chart.svg for data
import csv
import sys
import os
import re
import numpy as np
import matplotlib.pyplot as plt
def read_csv(path):
with open(sys.argv[1], newline = '') as fh:
return list(reversed(list([row for row in csv.DictReader(fh)])))
# check arguments
if len(sys.argv) < 3:
print("Usage: {} input.csv output.svg title xlimit".format(sys.argv[0]))
exit(-1)
# read csv
rows = read_csv(sys.argv[1])
# sort by range
# rows.sort(key = lambda row: int(row['range']))
# plot values
plt.barh(
np.arange(len(rows)),
[float(row['speed']) / 1048576 for row in rows],
align = 'center',
alpha = 0.5,
tick_label = ['{} ({} bytes)'.format(
row['host'],
row['size']
) for row in rows]
)
# # build title
# algo = os.path.splitext(os.path.basename(sys.argv[1]))[0]
# title = 'OpenSSL Speed Test: {}'.format(algo)
# get title and xlimit
title = sys.argv[3]
limit = int(sys.argv[4])
# # build xlimit
# # if re.match('^aes', algo):
# limit = 400
# else:
# limit = 2000
# add label and title
plt.yticks(fontsize = 5)
plt.xlim(0, limit)
# plt.xscale('log')
plt.xlabel('Speed (MB/s)')
plt.title(title, fontsize = 9)
plt.tight_layout()
# save image
plt.savefig(sys.argv[2])
|