Run time of Each Cell in the notebook

I am working on a notebook with some math calculations. And I got “notebook not responding” warnings frequently although the notebook just needs some time to calculate. I know it is probably hard to dismiss the warning, but I hope there is a way to show the run time of each cell. I would like to monitor which cell takes a long time to execute and optimize my code accordingly. Any suggestions?

The easiest way to find the offending cell might be to pause script execution in your developer tools:

4 Likes

Thank you so much! Very helpful advice! Could you also further explain the differences between the main thread and the worker thread?

The sandboxed notebook iframe (*.static.observableusercontent.com) runs in a different context than the parent window (observablehq.com), as would any web worker or service worker.

While debugging you may have noticed that pausing/breaking in one notebook will also pause any notebooks in other tabs. This is the reason why a single “freezing” notebook can freeze all other loaded notebooks.

1 Like