Guest User

Untitled

a guest
Jun 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # Time different findCaller strategies.
  3.  
  4. import logging
  5. import timeit
  6.  
  7. logger = logging.getLogger()
  8.  
  9. def filename_comparison():
  10. logger.info('This is a test for filename comparison')
  11.  
  12. def module_globals():
  13. logger.info('This is a test for module globals')
  14.  
  15. def do_timing(func):
  16. t = timeit.Timer(func)
  17. elapsed = t.timeit(number=1000000)
  18. print("%-20s %5.2f microseconds" % (func.__name__, elapsed))
  19.  
  20. def main():
  21. logging.basicConfig(level=logging.INFO, filename="timefc.log", filemode="w", format="%(funcName)s %(filename)s %(lineno)d %(message)s")
  22. do_timing(filename_comparison)
  23. logging._useglobals = True
  24. do_timing(module_globals)
  25.  
  26. if __name__ == "__main__":
  27. main()
Add Comment
Please, Sign In to add comment