Created
January 8, 2020 22:48
-
-
Save Abdelkrim/48ebeaaab5aa4948fd350c5127cae080 to your computer and use it in GitHub Desktop.
Python : Calculate time taken to execute a piece of code
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
# 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