I have a test suite and code it is testing. If I put from memory_profiler import profile
at the tops of the appropriate files, decorate the functions I want profiled with @profile
, and run in the standard way with python TestThing.py
, I get great line-by-line results.
But line_profiler doesn't come in a package this way, and the only way I have been able to profile anything with it is with kernprof -l -v thing.py
. If I use it on my unit tests, none of the tests are run (unsurprising, really), and no results are generated. How can I time-profile my tests and the code they use in a way analogous to memory_profiler?
of course, you could import line_profiler:
result stored in foo.lprof.
or, you could wrap a memory_profiler like decorator, print result after calling: