You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to test memory usage for a time-loop function? #366
Hi there, I wrote a time-loop function in my script wich is like this:
import numpy as np
def time_loop():
for i in range(0,10000000): # assume this is a time loop from x1 year x2 month x3 day to y1 year y2 month y3 day
# some codes
....
if __name__ == '__main__':
time_loop()
And I want to detect the memory usage of every line within the function time_loop. so how can I do that? does it simply follow:
import numpy as np
from memory_profiler import profile
@profile
def time_loop():
for i in range(0,10000000): # assume this is a time loop from x1 year x2 month x3 day to y1 year y2 month y3 day
# some codes
....
if __name__ == '__main__':
time_loop()
Then python -m memory_profile myscript.py? Thanks!
Activity