Beispiel #1
0
    def _test_mem_leakage_much_adding_some_removing(self):
        # measure one and throw it away, in order to reach a "steady state" in terms of initialization of memory state.
        memutil.measure_mem_leakage(self._mem_test_much_adding_some_removing, SAMPLES, iterspersample=2**0)
        slope = memutil.measure_mem_leakage(self._mem_test_much_adding_some_removing, SAMPLES, iterspersample=2**0)

        self.assertTrue(slope <= MIN_SLOPE,
                        "%s leaks memory at a rate of approximately %s system bytes per invocation" % (
                        self._mem_test_much_adding_some_removing, "%0.3f" % slope,))
Beispiel #2
0
    def _help_test_no_byte_leakage(self, f):
        # measure one and throw it away, in order to reach a "steady state" in terms of initialization of memory state.
        memutil.measure_mem_leakage(f, 2**3, iterspersample=2**3)
        slope = memutil.measure_mem_leakage(f, 2**3, iterspersample=2**3)

        # print "slope: ", slope
        MIN_SLOPE = 256.0 # If it leaks less than 256.0 bytes per iteration, then it's probably just some kind of noise from the interpreter or something...
        # MIN_SLOPE is high because samples is low, which is because doing statistically useful numbers of samples take too long.
        # For a *good* test, turn samples up as high as you can stand (maybe 2**8 for both invocations of measure_mem_leakage()) and set MIN_SLOPE to about 1.0.
        # For a *really* good test, add a variance measure to memutil.measure_mem_leakage(), and only consider it to be leaking if the slope is > 1.0 *and* is a "pretty good" fit for the data.
        # print "%s leaks memory at a rate of approximately %s system bytes per invocation" % (f, "%0.3f" % slope,)
        if slope > MIN_SLOPE:
            raise "%s leaks memory at a rate of approximately %s system bytes per invocation" % (f, "%0.3f" % slope,)
Beispiel #3
0
    def _test_mem_leakage(self):
        # measure one and throw it away, in order to reach a "steady state" in terms of initialization of memory state.
        memutil.measure_mem_leakage(self.test_em,
                                    max(2**3, SAMPLES / 2**3),
                                    iterspersample=2**0)
        slope = memutil.measure_mem_leakage(self.test_em,
                                            max(2**3, SAMPLES / 2**3),
                                            iterspersample=2**0)

        self.failUnless(
            slope <= MIN_SLOPE,
            "%s leaks memory at a rate of approximately %s system bytes per invocation"
            % (
                self.test_em,
                "%0.3f" % slope,
            ))
    def _test_mem_leakage_much_adding_some_removing(self):
        # measure one and throw it away, in order to reach a "steady state" in terms of initialization of memory state.
        memutil.measure_mem_leakage(self._mem_test_much_adding_some_removing, SAMPLES, iterspersample=2**0)
        slope = memutil.measure_mem_leakage(self._mem_test_much_adding_some_removing, SAMPLES, iterspersample=2**0)

        self.failUnless(slope <= MIN_SLOPE, "%s leaks memory at a rate of approximately %s system bytes per invocation" % (self._mem_test_much_adding_some_removing, "%0.3f" % slope,))