Greetings,
I wanted to know if there is a way to time the execution of a script run in PyCharm? Or, are there any intrinsic in the language to find the execution time?
Thanks,
Matt
profiling will show execution time in PyCharm.
As mention over
timit,often can code run fast in one time execution that it make no sense.
Example if we what to know if list comprehensions is faster that a ordinary loop an append.
So this run code 100000 times and we get an average time back.
import timeit
test = '''\
# Ordinary loop an append
lst = []
for i in range(1000):
lst.append(i)'''
test_lc = '''\
# The same with list comprehensions
lst = [i for i in range(1000)]'''
print(timeit.Timer(stmt=test).timeit(number=100000))
Output:
7.1943513999999995 # Ordinary loop
3.5672425000000003 # list comprehensions
So we see that in this case is list comprehensions faster.