本文整理汇总了Python中yappi.set_clock_type方法的典型用法代码示例。如果您正苦于以下问题:Python yappi.set_clock_type方法的具体用法?Python yappi.set_clock_type怎么用?Python yappi.set_clock_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yappi
的用法示例。
在下文中一共展示了yappi.set_clock_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _capture_profile
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import set_clock_type [as 别名]
def _capture_profile(fname=''):
if not fname:
yappi.set_clock_type('cpu')
# We need to set context to greenlet to profile greenlets
# https://bitbucket.org/sumerc/yappi/pull-requests/3
yappi.set_context_id_callback(
lambda: id(greenlet.getcurrent()))
yappi.set_context_name_callback(
lambda: greenlet.getcurrent().__class__.__name__)
yappi.start()
else:
yappi.stop()
stats = yappi.get_func_stats()
# User should provide filename. This file with a suffix .prof
# will be created in temp directory.
try:
stats_file = os.path.join(tempfile.gettempdir(), fname + '.prof')
stats.save(stats_file, "pstat")
except Exception as e:
print("Error while saving the trace stats ", str(e))
finally:
yappi.clear_stats()
示例2: init_yappi
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import set_clock_type [as 别名]
def init_yappi():
import atexit
import yappi
print('[YAPPI START]')
# yappi.set_clock_type('')
yappi.start()
@atexit.register
def finish_yappi():
print('[YAPPI STOP]')
yappi.stop()
print('[YAPPI WRITE]')
stats = yappi.get_func_stats()
for stat_type in ['pstat', 'callgrind', 'ystat']:
print('writing run_stats.{}'.format(stat_type))
stats.save('run_stats.{}'.format(stat_type), type=stat_type)
print('\n[YAPPI FUNC_STATS]')
print('writing run_stats.func_stats')
with open('run_stats.func_stats', 'w') as fh:
stats.print_all(out=fh)
print('\n[YAPPI THREAD_STATS]')
print('writing run_stats.thread_stats')
tstats = yappi.get_thread_stats()
with open('run_stats.thread_stats', 'w') as fh:
tstats.print_all(out=fh)
print('[YAPPI OUT]')
示例3: start_cpu_profiling
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import set_clock_type [as 别名]
def start_cpu_profiling():
yappi.set_clock_type("cpu")
yappi.start()
示例4: start_wall_profiling
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import set_clock_type [as 别名]
def start_wall_profiling():
yappi.set_clock_type("wall")
yappi.start()
示例5: _start
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import set_clock_type [as 别名]
def _start(self, config, current_time):
yappi.clear_stats()
clock = self._get_clock_type(
config.profile_clock, self._allowed_clocks, self._profile_clock
)
if clock != self._profile_clock:
self._profile_clock = clock
yappi.set_clock_type(self._profile_clock)
global_log.log(
scalyr_logging.DEBUG_LEVEL_0,
"Starting CPU profiling using '%s' clock. Duration: %d seconds"
% (self._profile_clock, self._profile_end - self._profile_start),
)
yappi.start()