Guest User

Untitled

a guest
Mar 18th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import time
  4.  
  5. ns = 2**(np.arange(4,14))
  6. times = np.zeros_like(ns, dtype='float')
  7. rep = 10
  8.  
  9. for count, n in enumerate(ns):
  10. im = np.random.random((n,n))
  11. im1 = np.copy(im)
  12.  
  13. trials = np.zeros(rep)
  14. for c in range(rep):
  15. t = time.time()
  16. im1 = np.copy(im)
  17. trials[c] = (time.time()-t)* 1e3 # convert sec to ms
  18.  
  19. times[count] = np.median(trials)
  20.  
  21.  
  22. print n, times[count]
  23.  
  24. plt.plot(ns, times, 'ro')
  25.  
  26. plt.xscale('log')
  27. plt.yscale('log')
  28.  
  29. plt.xlabel('Array size (nxn)')
  30. plt.ylabel('Time (sec)')
  31.  
  32.  
  33.  
  34.  
  35. plt.show()
Add Comment
Please, Sign In to add comment