Quick memory usage benchmarking in IPython

Posted by & filed under benchmarking, python.

Everybody loves %timeit, there’s no doubt about it. So why not have something like that, but for measuring how much memory your line takes? Well, now you can; grab a hold of the script in the following gist and run it like in the example.

Instead of taking care of the dirty process inspection stuff myself, I decided to delegate this to Fabian’s simple but very good memory_profiler. There is also Guppy available, but its design seems a bit and overkill for this task.

Please contact me if you find problems with this implementation, this is a preliminary, quick hack-y version. :)

4 Responses to “Quick memory usage benchmarking in IPython”

  1. Aaron MeurerNo Gravatar

    I know why it’s important to pick the minimum result for timeit, but I’m curious why this is also true for memory.

    Reply
    • veneNo Gravatar

      I didn’t give this too much thought. Maybe it makes more sense to take the maximum. The results are nearly identical over iterations anyway; it should work fine with -r1.

      Reply

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>