I am trying to use Snakeviz to profile my python code. I use
if __name__ == "__main__":
# main()
cProfile.run('main()', "stats.prof")
to start the profiling. The issue I am having is that Snakeviz is only showing one overall function "built-in method builtins.exec". Anyone know what could be causing this? The function I am profiling calls many sub-functions. Snakeviz sees this, as shown in the table excerpt below the image, it just doesn't show up in the visualisation.

cProfile.run does not seem to add callers data to the file.
Instead of using cProfile.run('main()', "stats.prof") try this:
pr = cProfile.Profile()
pr.enable()
main()
pr.disable()
pr.dump_stats("stats.prof")
Consider directly running cProfile from command line:
python -m cProfile -o output_file script_to_run.py
This will allow cProfile to understand your script's running time better.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With