本文整理汇总了Python中yappi.start方法的典型用法代码示例。如果您正苦于以下问题:Python yappi.start方法的具体用法?Python yappi.start怎么用?Python yappi.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yappi
的用法示例。
在下文中一共展示了yappi.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def main():
"""Just vgraph's main CLI function."""
parser = arg_parser()
args = parser.parse_args()
if args.profile:
import yappi
yappi.start()
try:
run_vgraph(parser, args)
finally:
yappi.stop()
stats = yappi.get_func_stats().sort('tsub').strip_dirs()
stats.print_all(out=sys.stderr, columns={0: ('name', 45), 1: ('ncall', 10), 2: ('tsub', 8), 3: ('ttot', 8), 4: ('tavg', 8)})
else:
run_vgraph(parser, args)
示例2: _start
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def _start(self, config, current_time):
if self._running:
return
self._running = True
global_log.log(
scalyr_logging.DEBUG_LEVEL_0,
"Starting memory profiling. Capture interval: %d seconds, duration: %d seconds"
% (self._capture_interval, self._profile_end - self._profile_start),
)
self._periodic_thread = PeriodicMemorySummaryCaptureThread(
capture_interval=self._capture_interval, name="MemoryCaptureThread"
)
self._periodic_thread.setDaemon(True)
self._periodic_thread.start()
示例3: move_to_next_task
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def move_to_next_task(self, workers_curr_step):
if self.config.opts("track", "test.mode.enabled"):
# don't wait if test mode is enabled and start the next task immediately.
waiting_period = 0
else:
# start the next task in one second (relative to master's timestamp)
#
# Assumption: We don't have a lot of clock skew between reaching the join point and sending the next task
# (it doesn't matter too much if we're a few ms off).
waiting_period = 1.0
m = self.metrics_store.to_externalizable(clear=True)
self.target.on_task_finished(m, waiting_period)
# Using a perf_counter here is fine also in the distributed case as we subtract it from `master_received_msg_at` making it
# a relative instead of an absolute value.
start_next_task = time.perf_counter() + waiting_period
for worker_id, worker in enumerate(self.workers):
worker_ended_task_at, master_received_msg_at = workers_curr_step[worker_id]
worker_start_timestamp = worker_ended_task_at + (start_next_task - master_received_msg_at)
self.logger.info("Scheduling next task for worker id [%d] at their timestamp [%f] (master timestamp [%f])",
worker_id, worker_start_timestamp, start_next_task)
self.target.drive_at(worker, worker_start_timestamp)
示例4: receiveMsg_StartWorker
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def receiveMsg_StartWorker(self, msg, sender):
self.logger.info("Worker[%d] is about to start.", msg.worker_id)
self.master = sender
self.worker_id = msg.worker_id
self.config = load_local_config(msg.config)
self.on_error = self.config.opts("driver", "on.error")
self.track = msg.track
track.set_absolute_data_path(self.config, self.track)
self.client_allocations = msg.client_allocations
self.current_task_index = 0
self.cancel.clear()
# we need to wake up more often in test mode
if self.config.opts("track", "test.mode.enabled"):
self.wakeup_interval = 0.5
runner.register_default_runners()
if self.track.has_plugins:
track.load_track_plugins(self.config, runner.register_runner, scheduler.register_scheduler)
self.drive()
示例5: __call__
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def __call__(self, *args, **kwargs):
import yappi
import io as python_io
yappi.start()
try:
return await self.target(*args, **kwargs)
finally:
yappi.stop()
s = python_io.StringIO()
yappi.get_func_stats().print_all(out=s, columns={
0: ("name", 140),
1: ("ncall", 8),
2: ("tsub", 8),
3: ("ttot", 8),
4: ("tavg", 8)
})
profile = "\n=== Profile START ===\n"
profile += s.getvalue()
profile += "=== Profile END ==="
self.profile_logger.info(profile)
示例6: start
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def start(self):
""" Start the processes """
global RedeemIsRunning
RedeemIsRunning = True
# Start the two processes
p0 = Thread(target=self.loop, args=(self.printer.commands, "buffered"), name="p0")
p1 = Thread(target=self.loop, args=(self.printer.unbuffered_commands, "unbuffered"), name="p1")
p0.daemon = True
p1.daemon = True
p0.start()
p1.start()
Alarm.executor.start()
Key_pin.listener.start()
if self.printer.config.getboolean('Watchdog', 'enable_watchdog'):
self.printer.watchdog.start()
self.printer.enable.set_enabled()
# Signal everything ready
logging.info("Redeem ready")
示例7: _capture_profile
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [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()
示例8: run
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def run(self, name: str, testdirn: str, coro, do_profiling=False) -> None:
for _ in range(self.num_iters):
# We set up the cortex each time to avoid intra-cortex caching
# (there's still a substantial amount of OS caching)
async with self.getCortexAndProxy() as (core, prox):
gc.collect()
gc.disable()
if do_profiling:
yappi.start()
start = time.time()
count = await coro(core, prox)
await s_lmdbslab.Slab.syncLoopOnce()
self.measurements[name].append((time.time() - start, count))
if do_profiling:
yappi.stop()
gc.enable()
renderProgress()
示例9: cmdloop
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def cmdloop(shell, func, args, use_yappi, single_command):
try:
if use_yappi:
import yappi
yappi.start()
func(*args)
yappi.get_func_stats().print_all()
else:
func(*args)
except (KeyboardInterrupt, SystemExit):
if not single_command:
shell.intro = terminal.fg_red() + \
"\nTo exit asadm utility please run exit command." + \
terminal.fg_clear()
cmdloop(shell, func, args, use_yappi, single_command)
示例10: init_yappi
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [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]')
示例11: main
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def main():
try:
if conf.ENABLE_PROFILING:
yappi.start()
launcher.main(sys.argv[1:])
yappi.stop()
else:
launcher.main(sys.argv[1:])
except KeyboardInterrupt:
if conf.ENABLE_PROFILING:
yappi.stop()
print('Yappi result (func stats) ======================')
yappi.get_func_stats().print_all()
print('Yappi result (thread stats) ======================')
yappi.get_thread_stats().print_all()
示例12: start_cpu_profiling
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def start_cpu_profiling():
yappi.set_clock_type("cpu")
yappi.start()
示例13: start_wall_profiling
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def start_wall_profiling():
yappi.set_clock_type("wall")
yappi.start()
示例14: start
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def start(self, command, repeat_count):
if self.remaining_count > 0:
print("Benchmark already running!")
return
self.repeat_count = repeat_count
self.remaining_count = repeat_count
self.command = command
self.start_time = time.time()
Mimic(*self.command.split()).execute()
示例15: normalize
# 需要导入模块: import yappi [as 别名]
# 或者: from yappi import start [as 别名]
def normalize(args):
"""Normalize variants."""
refs = Fastafile(expanduser(args.reference))
variants = VariantFile(args.sample)
with VariantFile(args.output, 'w', header=variants.header) as out:
# Create parallel locus iterator by chromosome
for _, ref, loci in records_by_chromosome(refs, [variants], [None], args):
loci = sort_almost_sorted(loci[0], key=NormalizedLocus.left_order_key)
for locus in loci:
record = locus.record
start = locus.left.start
stop = locus.left.stop
alleles = locus.left.alleles
if '' in alleles:
pad = ref[start - 1:start]
start -= 1
alleles = [pad + a for a in alleles]
record.alleles = alleles
record.start = start
record.stop = stop
out.write(record)