-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_real_speed_benchmark.py
68 lines (62 loc) · 1.91 KB
/
plot_real_speed_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
''' Plots the results of the complex FFT accuracy benchmark.
'''
import numpy as np
import matplotlib.pyplot as plt
from pathlib import Path
import h5py
import config
import lib
import sys
# if the save flag is passed, the plot is saved to file
save = False
if len(sys.argv) > 1 and sys.argv[1] == 'save':
save = True
# load all results
results = {}
for p in Path(config.SPEED_RESULT_DIR).iterdir():
if not p.is_file():
continue
results[p.stem] = h5py.File(str(p), mode='r')
# plot the results
fig, axs = plt.subplots(2, 2, figsize=(20.0/2.54, 20.0/2.54))
ax1, ax2, ax3, ax4 = axs.flat
i = 0
markers = ['>', '<', '+', 'x', '^']
styles = ['--', ':', '-.', '--', ':']
for k in sorted(results.keys()):
v = results[k]
kwargs = dict(label=k, marker=markers[i], ls=styles[i])
n = np.array(v['sizes'][:], dtype=np.int)
s = np.array(v['real_init'][:]) - np.array(v['real'][:])
# the values which are a power of two
f = (n != 0) & ((n & (n - 1)) == 0)
# the primes
fp = lib.is_prime(n)
# the non-power of two, non-primes -> regular (or Hamming) numbers
f2 = ~(f | fp)
lc1, = ax1.plot(n[f], v['real'][f], **kwargs)
lc2, = ax2.plot(n[f2], v['real'][f2], **kwargs)
lc3, = ax3.plot(n[fp], v['real'][fp], **kwargs)
# if k != 'pyfftw':
# # the primes do not require twiddle factors
# lc4, = ax4.plot(n[~fp], s[~fp], **kwargs)
i += 1
ax1.set_title('Power of Two')
ax2.set_title('Regular Numbers')
ax3.set_title('Primes')
#ax4.set_title('Twiddle Creation Time')
for ax in axs.flat[:-1]:
ax.set_yscale('log')
ax.set_xscale('log', basex=2)
ax.set_ylabel('runtime [s]')
ax.grid()
ax.set_xlabel('array size')
ax.legend(loc='best')
#ax4.set_ylabel('first runtime - best runtime [s]')
fig.suptitle('Runtime Real FFT')
fig.tight_layout()
fig.subplots_adjust(top=0.92)
if save:
fig.savefig('result_plots/speed_real.png', dpi=300)
else:
plt.show()