G2A Many GEOs
SHARE
TWEET

Untitled

a guest Jul 28th, 2017 355 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from time import time
  2. from functools import wraps
  3.  
  4.  
  5. def timeit(fn):
  6.     @wraps(fn)
  7.     def measure(*args, **kwargs):
  8.         start = time()
  9.         ret = fn(*args, **kwargs)
  10.         print(time() - start)
  11.         return ret
  12.     return measure
  13.  
  14.  
  15. @timeit
  16. def while_text():
  17.     i = 0
  18.     while 'computation occurs':
  19.         if i == 10000000:
  20.             break
  21.         i += 1
  22.  
  23.  
  24. @timeit
  25. def while_boolean():
  26.     pending = True
  27.     i = 0
  28.     while pending:
  29.         if i == 10000000:
  30.             pending = False
  31.         i += 1
  32.  
  33.  
  34. if __name__ == '__main__':
  35.  
  36.     print('test while text')
  37.     for x in range(15):
  38.         while_text()
  39.  
  40.     print('test while boolean')
  41.     for x in range(15):
  42.         while_boolean()
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