Advertisement
DeaD_EyE

sensless_speed_test

Jun 9th, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import numba
  2. import timeit
  3.  
  4.  
  5. @numba.jit
  6. def work():
  7.     """
  8.    This function is optimized by numba.
  9.    """  
  10.     a = 0
  11.     while a <= 1000000000:
  12.         a += 1
  13.     # to be sure, that this function is really called
  14.     return 42
  15.  
  16. if __name__ == '__main__':
  17.     print("Compiled")
  18.     print("Testing if function is working", end=" ")
  19.     if work() == 42:  
  20.         print("[ OK ]")
  21.     else:
  22.         print("[ FAIL ]")
  23.     jit_run = timeit.timeit(work)
  24.     print('The jitted version took {:.0f} ms'.format(jit_run * 1000))
  25.     print("Ended")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement