Skip to content

Instantly share code, notes, and snippets.

@vsajip
Created September 19, 2010 09:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsajip/586626 to your computer and use it in GitHub Desktop.
Save vsajip/586626 to your computer and use it in GitHub Desktop.
import logbook
import timeit
logger = logbook.Logger(__name__)
def log_noop():
pass
def log_simple():
logger.info("Testing")
def do_timing(func):
t = timeit.Timer(func)
elapsed = t.timeit(number=1000000)
print("%-20s %5.2f microseconds" % (func.__name__, elapsed))
def main():
handler = logbook.FileHandler('time_logbook.log', 'w', level='INFO')
with handler.applicationbound():
do_timing(log_noop)
do_timing(log_simple)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment