Skip to content

Instantly share code, notes, and snippets.

@DanHickstein
Created March 9, 2016 17:17
Show Gist options
  • Save DanHickstein/326d2df2d0a73c14cb1d to your computer and use it in GitHub Desktop.
Save DanHickstein/326d2df2d0a73c14cb1d to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import abel
sizes = np.logspace(np.log10(50), np.log10(1e4), 20)
n_max_bs = 2001
n_max_slow = 2001
transform_repeat = 4 # for less than 400
results = {'basex' : [],
'basex_bs': [],
'three_point': [],
'three_point_bs': [],
'direct_python': [],
'hansenlaw': [],
'direct_C': [] }
lines = {'basex' : [],
'basex_bs': [],
'three_point': [],
'three_point_bs': [],
'direct_python': [],
'hansenlaw': [],
'direct_C': [] }
ax = plt.subplot(111)
ax.set_xlabel('Image size (n)')
ax.set_ylabel('Time (ms)')
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlim(40,2e4)
ax.set_ylim(0.01,1e7)
plt.ion()
plt.show()
ns = []
first_time = True
for n in sizes:
n = int( (n//2)*2 + 1 )
print('size: %i'%n)
ns.append(n)
if n>400:
transform_repeat = 1
res = abel.benchmark.AbelTiming([n], n_max_bs=n_max_bs, n_max_slow=n_max_slow, transform_repeat=transform_repeat)
for name, color in zip (('basex', 'basex_bs', 'three_point','three_point_bs', 'direct_python', 'hansenlaw', 'direct_C'),
('b', 'b', 'r', 'r', 'm', 'g', 'purple')):
results[name].append(res.iabel[name])
if first_time:
if 'bs' in name:
ls = 'dashed'
marker = 's'
else:
ls = 'solid'
marker = 'o'
lines[name], = ax.plot(ns, results[name], ls=ls, label=name, marker=marker, color=color)
ax.legend(fontsize=10, frameon=False, loc=2, numpoints=1)
else:
lines[name].set_data( ns, results[name])
ax.relim()
ax.autoscale_view(True, True, True)
plt.draw(); plt.pause(0.001)
first_time = False
print 'complete!!'
plt.ioff()
plt.savefig('PyAbel bechmarks, nmin=%i, nmax=%i, steps=%i.png'%(np.min(sizes), np.max(sizes),np.shape(sizes)[0]),dpi=200)
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment