Created
January 20, 2021 21:33
-
-
Save TheoOkafor/0c9b044ca69dd8b4063cbf9c48ca7961 to your computer and use it in GitHub Desktop.
Test the runtime with and without print statement
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 | |
def test_runtime_with_print(): | |
start_time = time.time() | |
result = 0 | |
for i in range(100): | |
result = result + i | |
print(result) | |
print("======= WITH PRINT =======: {} milliseconds".format((time.time() - start_time) * 1000)) | |
return result | |
def test_runtime_without_print(): | |
start_time = time.time() | |
result = 0 | |
for i in range(99): | |
result = result + 1 | |
print("======= WITHOUT PRINT =======: {} milliseconds".format((time.time() - start_time) * 1000)) | |
return result | |
test_runtime_with_print() | |
test_runtime_without_print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment