SHARE
TWEET

Untitled

a guest Jun 20th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from numba import vectorize, int64
  2. import time
  3.  
  4. import numpy as np
  5.  
  6. num_loops = 50
  7. img_1 = np.ones((1000, 1000), np.int64) * 5
  8. img_2 = np.ones((1000, 1000), np.int64) * 10
  9. img_3 = np.ones((1000, 1000), np.int64) * 15
  10.  
  11. @vectorize([int64(int64, int64, int64)], target="parallel")
  12. def add_arrays(img_1, img_2, img_3):
  13.     return np.square(img_1 + img_2 + img_3)
  14.  
  15. start = time.time()
  16.  
  17. for i in range(num_loops):
  18.     result = add_arrays(img_1, img_2, img_3)
  19.  
  20. end = time.time()
  21. run_time = end - start
  22.  
  23. print("Average time = {}".format(run_time / num_loops))
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top