Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to test memory usage for a time-loop function? #366

Open
xushanthu-2014 opened this issue Oct 6, 2022 · 0 comments
Open

How to test memory usage for a time-loop function? #366

xushanthu-2014 opened this issue Oct 6, 2022 · 0 comments

Comments

@xushanthu-2014
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant