HOW TO: Find SLOW Code (3 ways in Python)
chinamatt chinamatt
1.48K subscribers
319 views
6

 Published On Dec 21, 2020

Here are 3 ways to find where your code is slowing you down.
1. %timeit -n 10 -r 2 myFunc( )
change the numbers as you like.
2. %prun myFunc( )
3. %lprun -f myFunc myFunc()
Activate using: %load_ext line_profiler

Install line_profiler by following this GitHub comment:
https://github.com/rkern/line_profile...

If there is still an error, you might need to install Visual Studio from Microsoft (which I will link below):
https://visualstudio.microsoft.com/th...

After installation, remember to restart your pc, and you should be able to pip install line profiler.

show more

Share/Embed