-
Notifications
You must be signed in to change notification settings - Fork 1
/
benchmark.py
74 lines (62 loc) · 2.23 KB
/
benchmark.py
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
67
68
69
70
71
72
73
74
#!/usr/bin/env python
from __future__ import print_function
import ast
import os
import subprocess
import sys
import glob
import re
import matplotlib
import matplotlib.pyplot as plt
import pprint
import numpy as np
path = os.path.dirname(os.path.realpath(__file__))
bin_dir = os.path.join(path, 'bin')
def plot(data, ticks, labels, file=None):
common_style = {'linestyle': '-', 'marker': 'o', 'markersize': 10.0, 'markeredgewidth': 2.0, 'markeredgecolor': '#FFFFFF'}
styles = [
dict(color = '#F6511D', **common_style),
dict(color = '#00A6ED', **common_style),
dict(color = '#7FB800', **common_style),
dict(color = '#FFB400', **common_style),
dict(color = '#0D2C54', **common_style),
]
grid_style = {'color': '#777777'}
figsize = (11, 5.5)
fig, ax = plt.subplots(figsize=figsize)
ax.grid(True, **grid_style)
for d, s, l in zip(data, styles, labels):
ax.set_xlabel('size')
ax.set_ylabel('mflops')
x = np.linspace(0,len(d),len(d), False)
ax.plot(x, d, linewidth=1.6, label=l, **s)
ax.set_ylim(bottom=0.0)
legend = ax.legend(loc='lower center', shadow=False)
legend.get_frame().set_alpha(0.6)
plt.xticks(x, ticks, rotation='vertical')
plt.tight_layout()
if not file:
plt.show()
else:
plt.savefig(file)
sizes = [2 ** x for x in range(0,7)]
exec_list = ['kfr','ipp']
def collect_data(type='float'):
labels = []
data = []
ticks = []
for exec_name in exec_list:
executable = os.path.join(bin_dir, 'dsp_benchmark_'+exec_name+'_'+type)
print(executable, '...')
output = subprocess.check_output([executable] + [str(size) for size in sizes]).splitlines()
algo = [line[len("Algorithm: "):] for line in output if line.startswith("Algorithm: ")][0]
labels.append(algo)
results = ast.literal_eval("\n".join([line[1:] for line in output if line.startswith(">")]))
for result in results:
ticks.append(result[0])
results = [result[4] for result in results]
pprint.pprint(results)
data.append(results)
return data, ticks, labels
data = collect_data()
plot(*data)