def _test_obj_leakage_much_adding_some_removing(self): # measure one and throw it away, in order to reach a "steady state" in terms of initialization of objects state. memutil.measure_obj_leakage(self._mem_test_much_adding_some_removing, SAMPLES, iterspersample=2**0) slope = memutil.measure_obj_leakage(self._mem_test_much_adding_some_removing, SAMPLES, iterspersample=2**0) self.assertTrue(slope <= MIN_SLOPE, "%s leaks objects at a rate of approximately %s system bytes per invocation" % ( self._mem_test_much_adding_some_removing, "%0.3f" % slope,))
def _help_test_no_obj_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_obj_leakage(f, 2**3, iterspersample=2**3) slope = memutil.measure_obj_leakage(f, 2**3, iterspersample=2**3) # print "slope: ", slope MIN_SLOPE = 0.0000 if slope > MIN_SLOPE: raise "%s leaks memory at a rate of approximately %s Python objects per invocation" % (f, slope,)
def _test_obj_leakage(self): # measure one and throw it away, in order to reach a "steady state" in terms of initialization of objects state. memutil.measure_obj_leakage(self.test_em, max(2**3, SAMPLES / 2**3), iterspersample=2**0) slope = memutil.measure_obj_leakage(self.test_em, max(2**3, SAMPLES / 2**3), iterspersample=2**0) self.failUnless( slope <= MIN_SLOPE, "%s leaks objects at a rate of approximately %s system bytes per invocation" % ( self.test_em, "%0.3f" % slope, ))
def _test_obj_leakage_much_adding_some_removing(self): # measure one and throw it away, in order to reach a "steady state" in terms of initialization of objects state. memutil.measure_obj_leakage(self._mem_test_much_adding_some_removing, SAMPLES, iterspersample=2**0) slope = memutil.measure_obj_leakage(self._mem_test_much_adding_some_removing, SAMPLES, iterspersample=2**0) self.failUnless(slope <= MIN_SLOPE, "%s leaks objects at a rate of approximately %s system bytes per invocation" % (self._mem_test_much_adding_some_removing, "%0.3f" % slope,))