Skip to content

Commit bbdd31d

Browse files
committed
restore diff
1 parent 946d6f7 commit bbdd31d

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

DEVELOP.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,3 +88,42 @@ Note that the `jupyter-mkdocs` plugin is only turned on when the `CI` env variab
8888
```
8989
CI=true uv run --group docs mkdocs serve
9090
```
91+
92+
## Profiling
93+
94+
### Python
95+
96+
I've come to really like [pyinstrument](https://pyinstrument.readthedocs.io/). pyinstrument is already included in the `dev` dependencies, or you can install it with pip. Then, inside a Jupyter notebook, load it with
97+
98+
```py
99+
%load_ext pyinstrument
100+
```
101+
102+
Then you can profile any cell with
103+
104+
```py
105+
%%pyinstrument
106+
# code to profile
107+
m = Map(...)
108+
```
109+
110+
It will print out a nice report right in the notebook.
111+
112+
### Widget display in Python
113+
114+
Sometimes the map _display_ is slow on the Python side. I.e. sometimes the map object generation `m = Map(...)` is fast, but then rendering with `m` in its own cell is slow before reaching JavaScript.
115+
116+
In this case, you can still use `pyinstrument` but you need to opt-in to the _explicit_ display:
117+
118+
```py
119+
from IPython.display import display
120+
121+
%%pyinstrument
122+
display(m)
123+
```
124+
125+
Otherwise, pyinstrument won't be able to hook into the display process.
126+
127+
### JavaScript rendering
128+
129+
Chrome's native performance profiler is the best tool I've used for this so far.

0 commit comments

Comments
 (0)