Algoteka
Log in to submit your own samples!

Measure Running Time of Code

Problem by oml1111
# Tech tags Title Creator Created date
1 0
2023-01-28 21:13
View all samples for this language (1 verified and 0 unverified)

Using time.time | Python |

By oml1111 |
0 likes

Measures the running time of a snippet of code using the time.time function from the python standard library

Code

from time import time

t = time()  # Timepoint before execution
a = [i*275 % 1000000007 for i in range(10000000)]
time_in_secs = time() - t

print('Execution took', time_in_secs, 'seconds')

References

functions
range docs.python.org
time.time docs.python.org

Problem Description

Run some demanding code snippet and measure how long it takes to execute.

View sample discussion (0 comments)
View problem discussion (0 comments)