Skip to content

Instantly share code, notes, and snippets.

@tbillington
Created August 22, 2014 12:52
Show Gist options
  • Save tbillington/83fd13a4edb0c7580cd4 to your computer and use it in GitHub Desktop.
Save tbillington/83fd13a4edb0c7580cd4 to your computer and use it in GitHub Desktop.
# Grab your time module !
import time
# Capture the time at the start of your program
time_at_start = time.time()
# The code you want to time goes here
for i in range(1,billion):
foo()
blah()
# End of code to be timed
# Capture the elapsed time between the start and now (the end of your program)
time_at_end = time.time() - time_at_start
# Print it ! Easy as pie !
print(time_at_end)
> 13.28290414810181
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment