Goal: I'm interested using this library to render speedscope files in a Jupyter. It seems hard to do this today, but with a few changes I think we can make this work. Ideally, we can load speedscope into an iframe with the right data. I'd also be interested in creating a customer juptyerlab mime render if that is a better option.
Background: With some recent changes, pyinstrument can now profile code in a notebook and also output to speedscope's format (ref). I'd like to be able to use speedscope's renderer inline in the notebook so I never need to leave my notebook as I try to optimize some code.
Problems:
Issues I ran into so far:
The cli makes assumptions about assets and accessing them. In Jupyter the browser and where the kernel lives may be on different hosts that can't access the same assets. If assets could optionally come from a CDN and be configured as such, that would make this much easier to use cross-host.
Today the CLI creates two files. It should be possible to to embed the generated js file into the html file so we can embed all the content into the notebook in an iframe. This comes down to always putting speedscope as a global.
There is one gotcha around accessing localstorage. The code here tries to only use it when available, but it turns out in an datauri iframe window.localstorage exists, but access it causes the code to throw.
In the end, I'd like the final html file to be able to look like below:
I like this for an "API" because it makes it easy to generate from any language and ensures there are no real restrictions on what main.js will do with the page.
These all seems pretty straight forward to solve and I'm happy to make a PR if you are open to moving in this direction.
@mlucool Have you made any progress on this? I'm trying to figure out the same scenario -- embedding speedscope in a jupyter notebook and passing data directly to it from a traitlet in the notebook.
Hi,
Goal: I'm interested using this library to render speedscope files in a Jupyter. It seems hard to do this today, but with a few changes I think we can make this work. Ideally, we can load speedscope into an iframe with the right data. I'd also be interested in creating a customer juptyerlab mime render if that is a better option.
Background: With some recent changes, pyinstrument can now profile code in a notebook and also output to speedscope's format (ref). I'd like to be able to use speedscope's renderer inline in the notebook so I never need to leave my notebook as I try to optimize some code.
Problems: Issues I ran into so far:
In the end, I'd like the final html file to be able to look like below:
I like this for an "API" because it makes it easy to generate from any language and ensures there are no real restrictions on what main.js will do with the page.
These all seems pretty straight forward to solve and I'm happy to make a PR if you are open to moving in this direction.
cc @joerick