Calculate execution time in Python

In any Python script you can easily count execution time. In Jupiter notebooks simply use built-in magic commands like

%%time

in the very beginning of the cell. Now with the IDEs like PyCharm you should use something like this:

import datetime as dt
t1 = dt.datetime.now()
# your code here
t2 = dt.datetime.now()
ft = t2 - t1
print("--- %s seconds ---" % ft.seconds)

You can actually also get seconds, days and even microseconds:

print("--- %s seconds ---" % ft.seconds)
print("--- %s ms ---" % ft.microseconds)
print("--- %s days ---" % ft.days)