Speed of ODE solving in R and Python

Published

November 7, 2024

import time

# Start the timer
start_time = time.time()

# Your code block
# Example:
for i in range(1000000):
    pass

# End the timer
end_time = time.time()

# Calculate and print the elapsed time
execution_time = end_time - start_time
print(f"Execution time: {execution_time} seconds")
Execution time: 0.021715879440307617 seconds
import timeit

# Define your code block as a function
def code_to_time():
    for i in range(1000000):
        pass

# Measure the execution time
execution_time = timeit.timeit(code_to_time, number=1)
print(f"Execution time: {execution_time} seconds")
Execution time: 0.008265999989816919 seconds