SHARE
TWEET

sensless_speed_test

DeaD_EyE Jun 9th, 2018 (edited) 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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")
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top