Skip to content

Instantly share code, notes, and snippets.

@Abdelkrim
Created January 8, 2020 22:48
Show Gist options
  • Save Abdelkrim/48ebeaaab5aa4948fd350c5127cae080 to your computer and use it in GitHub Desktop.
Save Abdelkrim/48ebeaaab5aa4948fd350c5127cae080 to your computer and use it in GitHub Desktop.
Python : Calculate time taken to execute a piece of code
# Python : Calculate time taken to execute a piece of code
import time
start_time = time.time()
a,b = 5,10
c = a+b
end_time = time.time()
time_taken = (end_time- start_time)*(10**6)
print("Time taken in micro_seconds:", time_taken) # Time taken in micro_seconds: 39.577484130859375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment