GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — How to test memory usage for a time-loop function? · Issue #366 · pythonprofilers/memory_profiler

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

New issue
Copy link
New issue
Copy link
Open
Open
How to test memory usage for a time-loop function?#366
Copy link

Description

@xushanthu-2014
xushanthu-2014
opened on Oct 6, 2022
Issue body actions

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.