carpentries-incubator / lesson-parallel-python

Parallel Programming in Python
https://carpentries-incubator.github.io/lesson-parallel-python/
Other
11 stars 15 forks source link

Add a few lines on profiling #102

Open HannoSpreeuw opened 2 years ago

HannoSpreeuw commented 2 years ago

During the debriefing meeting it was felt that we should say a few words on profiling, shortly after the introduction on the first day. The reason is that parallellisation should only be done after other options like optimizing single threaded code have been exhausted. So perhaps just before memory profiling, it would be good to teach two ways of identifying bottlenecks.

lprun, the line profiler:

!pip install line_profiler
%load_ext line_profiler
%lprun -f compute_mandelbrot_par compute_mandelbrot_par()

and prun:

prun -s cumulative myslowscript.py

Here is an article with extensive info.

Also, there is SO.