version: 0.50.0
In the official documentation. there is a link to this blog which give me instruction of how to make per-function memory usage plot. but when I try to run the exactly code in this post.
test1.py
import time
@profile
def test1():
n = 10000
a = [1] * n
time.sleep(1)
return a
@profile
def test2():
n = 100000
b = [1] * n
time.sleep(1)
return b
if __name__ == "__main__":
test1()
test2()
command is:
mprof run test1.py
I get this error:
Traceback (most recent call last):
File "test.py", line 3, in @profile NameError: name 'profile' is not defined
this is very strange, because there is the quotes from official :
Warning
If your Python file imports the memory profiler from memory_profiler import profile these timestamps will not be recorded. Comment out the import, leave your functions decorated, and re-run.
So if I want to have the per-function memory usage plot, I need comment out from memory_profiler import profile, but when I comment out it, there is a error.