Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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()
Add Comment
Please, Sign In to add comment