Advertisement
user_137

Inc1B

Oct 19th, 2014
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. def incALot(y):
  2.     x = 0
  3.     while x < y:
  4.         x += 1
  5.  
  6. @njit('i8(i8)')
  7. def nbIncALot(y):
  8.     x = 0
  9.     while x < y:
  10.         x += 1
  11.     return x
  12.  
  13. size = 1000000000
  14. start = time.time()
  15. incALot(size)
  16. t1 = time.time() - start
  17. start = time.time()
  18. x = nbIncALot(size)
  19. t2 = time.time() - start
  20. print('CPython3 takes %.3fs, Numba takes %.9fs' %(t1, t2))
  21. print('Speedup is: %.1f' % (t1/t2))
  22. print('Just Checking:', x)
  23.  
  24. CPython3 takes 58.958s, Numba takes 0.000007153s
  25. Speedup is: 8242982.2
  26. Just Checking: 1000000000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement