How to use the pympler.summary.print_ function in Pympler

To help you get started, we’ve selected a few Pympler examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pympler / pympler / test / muppy / test_summary.py View on Github external
def test_print_diff(self):
        """Test summary can be printed."""
        try:
            self._stdout = sys.stdout
            stream = StringIO()
            sys.stdout = stream
            sum1 = summary.summarize(muppy.get_objects())
            sum2 = summary.summarize(muppy.get_objects())
            sumdiff = summary.get_diff(sum1, sum2)
            summary.print_(sumdiff)
            self.assertIn('str', stream.getvalue())
            self.assertNotIn("
github Jenyay / outwiker / tests / utils.py View on Github external
def print_memory(count=30):
    '''
    Print the statistics of the objects in the memory.
    Need pympler to use.
    '''
    from pympler import muppy, summary

    gc.collect()
    all_objects = muppy.get_objects()
    my_types = muppy.filter(all_objects, Type=wx.Object)
    sum1 = summary.summarize(my_types)
    # sum1 = summary.summarize(all_objects)
    summary.print_(sum1, limit=count)
github HenryHu / pybbs / rosters.py View on Github external
def handle_signal_abort(self, signum, frame):
        Log.warn("Someone want to kill me! But I'll not die now! Hahahaha!")
        s = summary.summarize(muppy.get_objects())
        Log.debug("Current memory usage:")
        summary.print_(s)
        diff = summary.get_diff(self.mem_sum, s)
        self.mem_sum = s
        Log.debug("New memory usage:")
        summary.print_(diff)
github febert / visual_mpc / python / lsdc / utility / benchmarks.py View on Github external
def analyze_memory(tracker):
    all_objects = muppy.get_objects()
    num = len(all_objects)
    print 'number of objects:', num

    sum1 = summary.summarize(all_objects)
    print 'sumary of all objects'
    summary.print_(sum1)

    print 'difference: '
    tracker.print_diff()

    pdb.set_trace()
github genicam / harvesters / harvesters / _private / core / helper / profiler.py View on Github external
def summarize():
        summary.print_(
            summary.summarize(muppy.get_objects())
        )
github CloudBotIRC / CloudBot / plugins / profiling.py View on Github external
def pympler_summary():
    if pympler is None:
        return "pympler not installed / not enabled"
    all_objects = pympler.muppy.get_objects()
    summ = pympler.summary.summarize(all_objects)
    pympler.summary.print_(summ)
    return "Printed to console"
github Pyomo / pyomo / pyomo / core / base / PyomoModel.py View on Github external
tmp_clone_counter = expr_common.clone_counter
                    if clone_counter != tmp_clone_counter:
                        clone_counter = tmp_clone_counter
                        print("             Cloning detected! (clone count: %d)" % clone_counters)

            # Note: As is, connectors are expanded when using command-line pyomo but not calling model.create(...) in a Python script.
            # John says this has to do with extension points which are called from commandline but not when writing scripts.
            # Uncommenting the next two lines switches this (command-line fails because it tries to expand connectors twice)
            #connector_expander = ConnectorExpander()
            #connector_expander.apply(instance=self)

            if (pympler_available is True) and (profile_memory >= 2):
                print("")
                print("      Summary of objects following instance construction")
                post_construction_summary = summary.summarize(muppy.get_objects())
                summary.print_(post_construction_summary, limit=100)
                print("")
github jamesmeneghello / pynab / pynab / util.py View on Github external
def memory_usage(where):
    """Print out a basic summary of memory usage."""
    mem_summary = summary.summarize(muppy.get_objects())
    log.debug("Memory summary: {}".format(where))
    summary.print_(mem_summary, limit=2)
    log.debug("VM: {:2f}Mb".format(get_virtual_memory_usage_kb() / 1024.0))