當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。