Created
April 10, 2020 10:12
-
-
Save rodrigograca31/984d23f73f04ea21d05b12190d3e6d2a to your computer and use it in GitHub Desktop.
Test Python performance πβ‘
This file contains 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 time | |
times = 5000000 | |
def func1(): | |
return 5 + 5 | |
def func2(): | |
return 5 + 5 - 5 + 5 | |
print(func1()) | |
print(func2()) | |
start = time.time() | |
for x in range(times): | |
(func1()) | |
print("Imp 1: \t%.8f" % float(time.time() - start)) | |
start = time.time() | |
for x in range(times): | |
(func2()) | |
print("Imp 2: \t%.8f" % float(time.time() - start)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment