Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # Time different findCaller strategies.
- import logging
- import timeit
- logger = logging.getLogger()
- def filename_comparison():
- logger.info('This is a test for filename comparison')
- def module_globals():
- logger.info('This is a test for module globals')
- def do_timing(func):
- t = timeit.Timer(func)
- elapsed = t.timeit(number=1000000)
- print("%-20s %5.2f microseconds" % (func.__name__, elapsed))
- def main():
- logging.basicConfig(level=logging.INFO, filename="timefc.log", filemode="w", format="%(funcName)s %(filename)s %(lineno)d %(message)s")
- do_timing(filename_comparison)
- logging._useglobals = True
- do_timing(module_globals)
- if __name__ == "__main__":
- main()
Add Comment
Please, Sign In to add comment