4

line_profiler is a great Python package to find performance bottlenecks. The only complication when using it is that we have to specify each profiled module one by one on the command line:

%lprun -m toppkg.pkg1.module11 -m toppkg.pkg1.module12 ... -m toppkg.pkgN.moduleNK my_entry_point()

This can be a tedious task in a project of tens of thousands of line.

I wonder if anyone knows an automated approach, where we can specify all sub-packages and modules below a particular package like:

%mylprun -p toppkg my_entry_point()
Mark Horvath
  • 1,136
  • 1
  • 9
  • 24
  • one quick hack: `find toppkg -name '*.py' | grep -v __init__.py | cut -d. -f1 | tr / . | sed 's/^/-m /' | tr '\n' ' '` – Mark Horvath Oct 03 '15 at 19:58

0 Answers0