Reputation: 404
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.
Upvotes: 4
Views: 1838
Reputation: 578
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.
Upvotes: 1
Reputation: 5778
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")
Upvotes: 6