# 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 Meurer

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
• vene

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