From 18b0c1d3f3e43992a4770964efad172cf77c3462 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sun, 21 Jul 2019 02:09:16 -0400 Subject: initial commit --- plot.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 plot.py (limited to 'plot.py') diff --git a/plot.py b/plot.py new file mode 100755 index 0000000..d5f6863 --- /dev/null +++ b/plot.py @@ -0,0 +1,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]) -- cgit v1.2.3