Answers for "how check how long a python script takes to run"

3

how to time a python script

from datetime import datetime
start = datetime.now()
# some kind of code
print(datetime.now() - start)
Posted by: Guest on July-07-2020
-1

check runtime python

import timeit

code = """[4, 2, 3, 1, 5].sort()"""

execution_time = timeit.timeit(code, number=1)

print(execution_time)
Posted by: Guest on November-08-2020

Code answers related to "how check how long a python script takes to run"

Python Answers by Framework

Browse Popular Code Answers by Language