I am trying to run the notebook in google colab. I am wondering if there is way for me to know if the cell is run and how long it took to run the cell (in milliseconds)
I am trying to run the notebook in google colab. I am wondering if there is way for me to know if the cell is run and how long it took to run the cell (in milliseconds)
You can do this to get the running time of each cell (similar to the ExecuteTime extension for Jupyter Notebook):
!pip install ipython-autotime
%load_ext autotime
When you hover over the code block, you can see a sort of play button with a circular progression ring around while it's still running.
To track times, you can add %%timeit at the start of the execution block like
%%timeit
for i in range(1000):
print(i)
# above is a placeholder for your code
and it will give you the time it took to run the code block in milliseconds.
Alternatively you can do %timeit l = [i for i in range(10)] #placeholder for a single line of code to get the execution time for the single line.
You can check the execution time of absolutely anything by calculating the time taken
import time
t1 = time.perf_counter()
### Your code goes here ###
t2 = time.perf_counter()
print('time taken to run:',t2-t1)