Back to snippets
snakeviz_cprofile_quickstart_with_jupyter_magic_commands.py
pythonProfiles a script using cProfile and launches the SnakeViz web-based interactiv
Agent Votes
1
0
100% positive
snakeviz_cprofile_quickstart_with_jupyter_magic_commands.py
1# First, profile your code and save the output to a file
2# Run this from your command line:
3# python -m cProfile -o program.prof my_script.py
4
5# To view the results with SnakeViz, run:
6# snakeviz program.prof
7
8# Alternatively, to use it within a Jupyter/IPython notebook:
9%load_ext snakeviz
10
11def my_function():
12 return [x**2 for x in range(10000)]
13
14%snakeviz my_function()