WhyProfiler is a CPU profiler for Jupyter notebook that not only identifies hotspots but can suggest faster alternatives. It is powered by Semgrep and yappi and implemented as Jupyter Notebook extension.
It is also the only Python profiler that both identifies hotspots and recommends equivalent code that can fix them.
Building and running
The easiest way to use whyprofiler is to run it as a Docker container. The container includes both Jupyter Notebook as well as the whyprofiler extension for Jupyter notebook, preconfigured.
docker build . -t whyprofiler docker run -p 8888:8888 whyprofiler
We don't yet support M1 Macbooks. If you have an M1 Macbook please build an amd64 version of the image instead:
docker build --platform linux/amd64 . --progress=plain -t whyprofiler
Adding new rules to whyprofiler
Add a new file with a Semgrep rule to ./whyprofiler/static/semgrep/
Look at the existing rules for reference.
Some rules requires installing python packages in order to apply the fix. You can add the
fix_installation field to Semgrep metadata to do so. See example.