https://letmaik.github.io/profviewer
An experiment for viewing runtime profiles online in a fully static website.
Features:
- Profile files are not uploaded but locally read.
- gprof2dot and flameprof integration via pyodide, powered by WebAssembly.
- FlameGraph integration via WebPerl, powered by WebAssembly.
- Graphviz rendering via d3-graphviz, powered by WebAssembly.
- Sortable table for pstats (Python) profiles.
- Load zipped profiles via JSZip.
- Load profiles from URLs (e.g. from GitHub issue attachments).
Future ideas:
- Table display for more profile formats
- Flame graphs for more profile formats
Python does not guarantee file compatibility for cProfile/profile files between Python versions or operating systems. The current pyodide version uses Python 3.7. If the profile can't be read, then "ValueError: bad marshal data (unknown type code)" will be shown.
Running flameprof will error with "maximum recursion depth exceeded" for bigger profiles. This is because it relies on recursion which in pyodide relies on JavaScript recursion. Since one Python call translates to multiple JavaScript call frames, the effective browser limit (Firefox ~439, Chrome ~315) is much lower than for regular Python (1000). Ideally, flameprof should be fixed as it seems likely that it may also fail for bigger profiles on regular Python.
FlameGraph is a Perl script which is run via WebPerl. Unfortunately, WebPerl currently has the limitation that it can only be run once, there is no way to restart the interpreter. That means, if the FlameGraph button is pressed again, an error is shown explaining that. The demo pages of WebPerl work around that by using IFrames, but for this experimental project it's not worth the effort.
Just start a web server, no compilation needed:
python -m http.server