[Networkit] measuring memory usage with IPython and the memory_profiler

Christian Staudt christian.staudt at kit.edu
Sat Nov 15 09:53:02 CET 2014

Hi all,
I’ve recently discovered an easy way to measure peak memory usage for NetworKit code. 

First install the Python modules psutil and memory_profiler, e.g. with

>>> pip install psutil
>>> pip install memory_profiler

From an IPython shell, use the %memit command to show peak memory usage of the Python process and incremental memory usage of the piece of code being profiled. In this case, reading the graph took 2.59 MB additional memory and running Betweenness took 6.99 MB more.

In [1]: %load_ext memory_profiler

In [2]: from networkit import *

In [3]: %memit G = readGraph("/Users/cls/workspace/NetworKit/input/PGPgiantcompo.graph")
peak memory: 79.37 MiB, increment: 2.59 MiB

In [5]: %memit centrality.Betweenness(G).run()
peak memory: 87.26 MiB, increment: 6.99 MiB


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20141115/0a469cfa/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <https://lists.ira.uni-karlsruhe.de/mailman/private/networkit/attachments/20141115/0a469cfa/attachment.sig>

More information about the NetworKit mailing list