pythonprofilers / memory_profiler

Monitor Memory usage of Python code
http://pypi.python.org/pypi/memory_profiler
Other
4.39k stars 380 forks source link

ipython magic mprun doesn't work for multiple parameters #295

Open bsipocz opened 4 years ago

bsipocz commented 4 years ago

I yet to pin down the issue here, but there seem to some problems with %mprun when trying to run it for a function with multiple parameters.

In [26]: %mprun -f compute_XD_results(500, 5, 500)                                                                      
UsageError: Could not find function 'compute_XD_results(500,'.
SyntaxError: unexpected EOF while parsing (<string>, line 1)

While it seems to do something, it doesn't return any results. %memit works as expected.

In [27]: %mprun -f compute_XD_results(500) 
PaulHancock commented 3 years ago

I believe that you need to do the following: %mprun -f compute_XD_results compute_XD_results(500, 5, 500) the -f flag tells mprun which function needs profiling (just the function name) separate from the actual invocation of the function (which requires arguments)