Skip to content

Instantly share code, notes, and snippets.

@DanHickstein
Last active March 9, 2018 15:34
Show Gist options
  • Save DanHickstein/a0536df5d08bc3442babe94550083895 to your computer and use it in GitHub Desktop.
Save DanHickstein/a0536df5d08bc3442babe94550083895 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import time
ns = 2**(np.arange(4,14))
times = np.zeros_like(ns, dtype='float')
rep = 10
for count, n in enumerate(ns):
im = np.random.random((n,n))
im1 = np.copy(im)
trials = np.zeros(rep)
for c in range(rep):
t = time.time()
im1 = np.copy(im)
trials[c] = (time.time()-t)* 1e3 # convert sec to ms
times[count] = np.median(trials)
print n, times[count]
plt.plot(ns, times, 'ro')
plt.xscale('log')
plt.yscale('log')
plt.xlabel('Array size (nxn)')
plt.ylabel('Time (sec)')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment