Advertisement
DigitalMag

Numba benchmark range (1000x)

Jan 7th, 2020
437
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.58 KB | None | 0 0
  1. from numba import jit
  2. import time
  3. import math
  4.  
  5. @jit(nopython=True)
  6. def bench(n):
  7.     s = 0
  8.     for i in range(n):
  9.         s+=(2*3)%7  #math.sin(i)
  10.     return s
  11.  
  12. def main(n):
  13.     for i in range(n):
  14.         t = time.time()
  15.  
  16.         s = bench(10000000)
  17.  
  18.         d = time.time() - t
  19.  
  20.         if i == 0:
  21.             f = input('ddd:')
  22.  
  23.         print d
  24.         print s
  25.  
  26.  
  27. if __name__ == '__main__':
  28.     main(3)
  29.  
  30. """
  31. 1.24100017548
  32. 60000000
  33. 0.0
  34. 60000000
  35. 0.0
  36. 60000000
  37.  
  38. without jit:
  39.  
  40. 1.93700003624
  41. 60000000
  42. 1.80199980736
  43. 60000000
  44. 1.83800005913
  45. 60000000
  46. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement