Created
September 19, 2010 09:40
-
-
Save vsajip/586626 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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