当前位置: 首页>>代码示例>>Python>>正文


Python summary.summarize方法代码示例

本文整理汇总了Python中pympler.summary.summarize方法的典型用法代码示例。如果您正苦于以下问题:Python summary.summarize方法的具体用法?Python summary.summarize怎么用?Python summary.summarize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pympler.summary的用法示例。


在下文中一共展示了summary.summarize方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: print_muppy_sumary

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def print_muppy_sumary():
    # http://pythonhosted.org/Pympler/index.html
    try:
        from pympler import muppy, summary
    except ImportError:
        print("WARNING: pympler not installed")
        return
    # from pympler.classtracker import ClassTracker
    # from pympler.classtracker_stats import HtmlStats
    global all_objects, obj_summary, class_tracker
    if all_objects is None:
        all_objects = muppy.get_objects()
        obj_summary = summary.summarize(all_objects)
        summary.print_(obj_summary)

        # class_tracker = ClassTracker()
        # class_tracker.track_class(FICSPlayer, trace=1)
        # class_tracker.track_class(ICGameModel, resolution_level=2, trace=1)
    else:
        obj_summary2 = summary.summarize(muppy.get_objects())
        diff = summary.get_diff(obj_summary, obj_summary2)
        summary.print_(diff, limit=200)

        # class_tracker.create_snapshot('usage')
        # HtmlStats(tracker=class_tracker).create_html('profile.html') 
开发者ID:pychess,项目名称:pychess,代码行数:27,代码来源:debug.py

示例2: _create_app_impl

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def _create_app_impl(self, app):
        @app.route('/profile')
        def profile():
            if self.profiler is None:
                return 'Profiling disabled\n', 404
            resp = self.profiler.stats()
            if request.args.get('reset ') in (1, 'true'):
                self.profiler.reset()
            return resp

        @app.route('/load')
        def load():
            if self.tracer is None:
                return 'Load tracing disabled\n', 404
            resp = jsonify(self.tracer.stats())
            if request.args.get('reset ') in (1, 'true'):
                self.tracer.reset()
            return resp

        @app.route('/mem')
        def mem():
            objs = muppy.get_objects()
            summ = summary.summarize(objs)
            return '\n'.join(summary.format_(summ)) + '\n' 
开发者ID:nylas,项目名称:sync-engine,代码行数:26,代码来源:frontend.py

示例3: memory_profiler

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def memory_profiler(self):
        all_objects = muppy.get_objects()
        stats = summary.summarize(all_objects)
        return {'Memory_profiler': [l for l in summary.format_(stats, LIMIT_OBJECTS_FOR_PROFILER)]} 
开发者ID:hyperledger,项目名称:indy-plenum,代码行数:6,代码来源:validator_info_tool.py

示例4: print_summary

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def print_summary():
    """Print a summary of all known objects."""
    summary.print_(summary.summarize(get_objects())) 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:5,代码来源:muppy.py

示例5: __init__

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def __init__(self, ignore_self=True):
        """Constructor.

        The number of summaries managed by the tracker has an performance
        impact on new summaries, iff you decide to exclude them from further
        summaries. Therefore it is suggested to use them economically.

        Keyword arguments:
        ignore_self -- summaries managed by this object will be ignored.
        """
        self.s0 = summary.summarize(muppy.get_objects())
        self.summaries = {}
        self.ignore_self = ignore_self 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:15,代码来源:tracker.py

示例6: print_diff

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def print_diff(self, ignore=[]):
        """Print the diff to the last time the state of objects was measured.

        keyword arguments
        ignore -- list of objects to ignore
        """
        # ignore this and the caller frame
        ignore.append(inspect.currentframe()) #PYCHOK change ignore
        diff = self.get_diff(ignore)
        print("Added objects:")
        summary.print_(summary.summarize(diff['+']))
        print("Removed objects:")
        summary.print_(summary.summarize(diff['-']))
        # manual cleanup, see comment above
        del ignore[:] 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:17,代码来源:tracker.py

示例7: on_epoch_end

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def on_epoch_end(self, epoch, log={}):
        x = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
        web_browser_debug = True
        print(x)

        if x > 40000:
            if web_browser_debug:
                if epoch==0:
                    start_in_background()
                    tr = tracker.SummaryTracker()
                    tr.print_diff()
            else:
                global memlist
                all_objects = muppy.get_objects(include_frames=True)
                # print(len(all_objects))
                sum1 = summary.summarize(all_objects)
                memlist.append(sum1)
                summary.print_(sum1)
                if len(memlist) > 1:
                    # compare with last - prints the difference per epoch
                    diff = summary.get_diff(memlist[-2], memlist[-1])
                    summary.print_(diff)
                my_types = muppy.filter(all_objects, Type=types.ClassType)

                for t in my_types:
                    print(t)


    ######################################################### 
开发者ID:robmsmt,项目名称:KerasDeepSpeech,代码行数:31,代码来源:utils.py

示例8: _capture_snapshot

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def _capture_snapshot(self):
        # type: () -> None
        """
        Capture memory usage snapshot.
        """
        capture_time = int(time.time())

        # 1. Capture aggregate values
        all_objects = muppy.get_objects()
        all_objects = self._filter_muppy_objects(all_objects)
        sum1 = summary.summarize(all_objects)
        data = summary.format_(sum1, limit=50)

        item = {
            "timestamp": capture_time,
            "data": list(data),
            "type": "aggregated",
        }
        self._profiling_data.append(item)

        # 2. Capture diff since the last capture
        data = self._tracker.format_diff()
        item = {
            "timestamp": capture_time,
            "data": list(data),
            "type": "diff",
        }
        self._profiling_data.append(item) 
开发者ID:scalyr,项目名称:scalyr-agent-2,代码行数:30,代码来源:profiler.py

示例9: __exit__

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def __exit__(self, exc_type, exc_val, exc_tb):
        if self.debug:
            try:
                gc.collect()
                end_memory = self.process.memory_info().rss
                net_memory = end_memory-self.start_memory
                if net_memory > 100 * 1000 * 1000:
                    Log.warning(
                        "MEMORY WARNING (additional {{net_memory|comma}}bytes): "+self.description,
                        default_params=self.params,
                        net_memory=net_memory
                    )

                    from pympler import summary
                    from pympler import muppy
                    sum1 = sorted(summary.summarize(muppy.get_objects()), key=lambda r: -r[2])[:30]
                    Log.warning("{{data}}", data=sum1)
                elif end_memory > 1000*1000*1000:
                    Log.warning(
                        "MEMORY WARNING (over {{end_memory|comma}}bytes): "+self.description,
                        default_params=self.params,
                        end_memory=end_memory
                    )

                    from pympler import summary
                    from pympler import muppy
                    sum1 = sorted(summary.summarize(muppy.get_objects()), key=lambda r: -r[2])[:30]
                    Log.warning("{{data}}", data=sum1)

            except Exception as e:
                Log.warning("problem in memory measure", cause=e) 
开发者ID:mozilla,项目名称:jx-sqlite,代码行数:33,代码来源:meta.py

示例10: dump_objs

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def dump_objs():
	global TRACKER
	if TRACKER is None:
		TRACKER = tracker.SummaryTracker()

	with open("obj_log.txt", "a") as fp:
		fp.write("Memory at {}\n".format(str(datetime.datetime.now())))
		try:
			all_objects = muppy.get_objects()
			sum1 = summary.summarize(all_objects)
			str_sum  = summary.format_(sum1)

			fp.write("Summary:\n")
			for line in str_sum:
				fp.write("	{}\n".format(line))
		except Exception:
			err = traceback.format_exc()
			fp.write("Error: \n")
			fp.write(err)

		try:
			str_diff = TRACKER.format_diff()
			fp.write("Diff:\n")
			for line in str_diff:
				fp.write("	{}\n".format(line))
		except Exception:
			err = traceback.format_exc()
			fp.write("Error: \n")
			fp.write(err)

		fp.write("\n") 
开发者ID:fake-name,项目名称:IntraArchiveDeduplicator,代码行数:33,代码来源:server.py

示例11: create_summary

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import summarize [as 别名]
def create_summary(self):
        """Return a summary.

        See also the notes on ignore_self in the class as well as the
        initializer documentation.

        """
        if not self.ignore_self:
            res = summary.summarize(muppy.get_objects())
        else:
            # If the user requested the data required to store summaries to be
            # ignored in the summaries, we need to identify all objects which
            # are related to each summary stored.
            # Thus we build a list of all objects used for summary storage as
            # well as a dictionary which tells us how often an object is
            # referenced by the summaries.
            # During this identification process, more objects are referenced,
            # namely int objects identifying referenced objects as well as the
            # correspondind count.
            # For all these objects it will be checked wether they are
            # referenced from outside the monitor's scope. If not, they will be
            # subtracted from the snapshot summary, otherwise they are
            # included (as this indicates that they are relevant to the
            # application).

            all_of_them = []  # every single object
            ref_counter = {}  # how often it is referenced; (id(o), o) pairs
            def store_info(o):
                all_of_them.append(o)
                if id(o) in ref_counter:
                    ref_counter[id(o)] += 1
                else:
                    ref_counter[id(o)] = 1

            # store infos on every single object related to the summaries
            store_info(self.summaries)
            for k, v in self.summaries.items():
                store_info(k)
                summary._traverse(v, store_info)

            # do the summary
            res = summary.summarize(muppy.get_objects())

            # remove ids stored in the ref_counter
            for _id in ref_counter:
                # referenced in frame, ref_counter, ref_counter.keys()
                if len(gc.get_referrers(_id)) == (3):
                    summary._subtract(res, _id)
            for o in all_of_them:
                # referenced in frame, summary, all_of_them
                if len(gc.get_referrers(o)) == (ref_counter[id(o)] + 2):
                    summary._subtract(res, o)

        return res 
开发者ID:lrq3000,项目名称:pyFileFixity,代码行数:56,代码来源:tracker.py


注:本文中的pympler.summary.summarize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。