Skip to content

Instantly share code, notes, and snippets.

@vndee
Created June 21, 2024 16:53
Show Gist options
  • Save vndee/b8f77fca12b969c7bbf8760f1581c982 to your computer and use it in GitHub Desktop.
Save vndee/b8f77fca12b969c7bbf8760f1581c982 to your computer and use it in GitHub Desktop.
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