Created
June 21, 2024 16:53
-
-
Save vndee/b8f77fca12b969c7bbf8760f1581c982 to your computer and use it in GitHub Desktop.
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 | |
# Simulate a CPU-bound task | |
def compute_factorial(n): | |
if n == 0: | |
return 1 | |
else: | |
return n * compute_factorial(n-1) | |
# Calling the CPU-bound task | |
start_time = time.time() | |
result = compute_factorial(20) | |
end_time = time.time() | |
print(f"Computed factorial in {end_time - start_time} seconds") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment