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


Python summary.format_方法代码示例

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


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

示例1: _create_app_impl

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import format_ [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

示例2: snapshot

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import format_ [as 别名]
def snapshot(self, snapshot_name):
    """ Snapshot the memory

    Returns [geneorator of str] - formated memory snapshot or diff surrounded by
    dividing line. When this method is called for the first time, the full
    snapshot will be returned. After that,  it will only return the diff with
    the previous snapshot.
    """
    sum = self._tracker.create_summary()
    last_snapshot_name = self._current_snapshot_name
    self._current_snapshot_name = snapshot_name
    if self._diff_snapshot:
      yield ((
        '-------- Diff between current snapshot (%s) and last snapshot (%s) '
        'Starts --------') % (snapshot_name, last_snapshot_name))
      diff = self._tracker.diff(summary1=sum)
      # TODO(yiwzhang): switch to yield from after moving to python 3
      for diff_line in summary.format_(diff):
        yield diff_line
      yield ((
        '-------- Diff between current snapshot (%s) and last snapshot (%s) '
        'Ends --------') % (snapshot_name, last_snapshot_name))
    else:
      # create_summary() won't make the return value latest summary in the
      # underlying tracker. Manually moving it forward
      self._tracker.s0 = sum
      # Only dump the full snapshot when this method is called for the first
      # time. From then onwards, dump diff only
      self._diff_snapshot = True
      yield '-------- Memory Snapshot (%s) Start --------' % snapshot_name
      # TODO(yiwzhang): switch to yield from after moving to python 3
      for snapshot_line in summary.format_(sum):
        yield snapshot_line
      yield '-------- Memory Snapshot (%s) Ends --------' % snapshot_name 
开发者ID:luci,项目名称:recipes-py,代码行数:36,代码来源:engine.py

示例3: memory_profiler

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import format_ [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: _capture_snapshot

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import format_ [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

示例5: dump_objs

# 需要导入模块: from pympler import summary [as 别名]
# 或者: from pympler.summary import format_ [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


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