Our standard test has gotten out of control. The most serious problem is that running a full test suite now fails on a linux VM with 4 GB--it's out of memory. Half-way through the set, it is already using more than 2 GB. That's ridiculous. Running nosetests separately on each test module keeps the max reported by top to 1.6 GB, and the max by report_memory to 0.5 GB; still quite a bit, but tolerable. (I don't know why there is this factor of 3 between top and report_memory.) This scheme of running test modules one at a time also speeds it up by a factor of 2; I don't understand why.

The script I used for the module-at-a-time test is attached. It is a modification of matplotlib.tests().

Are there any nosetest experts out there with ideas about how to streamline the standard test routine?

Eric
"""
Run the tests one module at a time to keep the memory usage under
control.

Skip a couple of modules that take a long time to test, and that we
are not likely to be affecting.
"""


from __future__ import print_function

import matplotlib as mpl
from matplotlib import rcParams, default_test_modules, use

from matplotlib.cbook import report_memory

def test(verbosity=1):
    """run the matplotlib test suite"""
    old_backend = rcParams['backend']
    try:
        use('agg')
        import nose
        import nose.plugins.builtin
        from matplotlib.testing.noseclasses import KnownFailure
        from nose.plugins.manager import PluginManager
        from nose.plugins import multiprocess

        # store the old values before overriding
        plugins = []
        plugins.append( KnownFailure() )
        plugins.extend( [plugin() for plugin in nose.plugins.builtin.plugins] )

        manager = PluginManager(plugins=plugins)
        config = nose.config.Config(verbosity=verbosity, plugins=manager)

        # Nose doesn't automatically instantiate all of the plugins in the
        # child processes, so we have to provide the multiprocess plugin with
        # a list.
        multiprocess._instantiate_plugins = [KnownFailure]

        successes = []

        for mod in default_test_modules:
            # Skip slow tests likely to be irrelevant:
            #if 'delaunay' in mod or 'mathtext' in mod:
            #    continue

            print(mod, report_memory())
            success = nose.run( defaultTest=[mod],
                            config=config,
                            )
            print(report_memory())
            successes.append((mod, success))

    finally:
        if old_backend.lower() != 'agg':
            use(old_backend)

    return successes

if __name__ == '__main__':
    import time
    start = time.time()
    successes = test()
    for mod, s in successes:
        print(s, mod)
    print("\nelapsed time: %f" % (time.time() - start))

------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to