[TIP] Tracking memory usage during tests

Stefan Scherfke stefan at sofa-rockers.org
Sun Mar 30 10:36:50 PDT 2014

Am 2014-03-30 um 18:23 schrieb Thomas Trenner <thomas.trenner at gmail.com>:

> Hi,
> I'm using py.test to run interface and high-level tests for a C++ library (Win7, via a python interface). 
> I am also using the timings coming from the junit-xml output to do some statistical analysis 
> that should detect any performance degradations. One other thing I am concerned about though
> is memory usage - as the actual memory-allocating code is written in C++.
> Does anyone know of an approach that would give me memory usage statistics while running the
> tests? I thought about changing the assert statements to first log the memory usage of the process
> before doing the actual assert, using something like psutil, but I am not sure whether this will give a 
> useful metric? One key question there is whether py.test - in single-process mode - will always run 
> the tests in the same order unless tests are added/removed?
> I welcome any suggestions on alternative approaches.

You could take a look at https://pypi.python.org/pypi/memory_profiler
I’m not sure if it will work with C++ extensions, though.


> Thanks,
> Thomas
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python

More information about the testing-in-python mailing list