jlfwong / speedscope

🔬 A fast, interactive web-based viewer for performance profiles.
https://www.speedscope.app
MIT License
5.59k stars 246 forks source link

Native support for cProfile dump #477

Open arunoruto opened 6 months ago

arunoruto commented 6 months ago

I want to analyze some code and I do really love your project! The only problem ist, cProfile is the only tool that gives me reasonable outputs, without crashing. Sadly, speedscope does not support their profile dumps.

Is there a way to make them readable? I was able to use flameprof to generate an SVG, but that's it, it can't be interacted with or zoomed in.

If there is not alternative, maybe I will try to implement a translator from cProfile dump files to speedscope json files, but I am booked out until end of june.

jlfwong commented 6 months ago

Hi @arunoruto!

I'd accept a patch to import them directly. I suspect you can already import them if you just use the output of flameprof --format=log requests.prof. I'm guessing this outputs in the format that flamegraph.pl accepts, which speedscope already supports as an input format.

Let me know if that works!

arunoruto commented 4 months ago

Sorry for the late follow up! I tried your suggestion and it worked out pretty well! I am finally able to convert my cProfile dumps to something readable by speedscope 😁

It would be cool to have that integrated inside of speedscope, but for now I am also satisfied with this solution! Maybe I will look into converting the files in my script before dumping them.