本文整理汇总了Python中profile.Profile.runcall方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.runcall方法的具体用法?Python Profile.runcall怎么用?Python Profile.runcall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profile.Profile
的用法示例。
在下文中一共展示了Profile.runcall方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _exec_main
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import runcall [as 别名]
def _exec_main(parser, values):
sconsflags = os.environ.get('SCONSFLAGS', '')
all_args = sconsflags.split() + sys.argv[1:]
options, args = parser.parse_args(all_args, values)
if isinstance(options.debug, list) and "pdb" in options.debug:
import pdb
pdb.Pdb().runcall(_main, parser)
elif options.profile_file:
# compat layer imports "cProfile" for us if it's available.
from profile import Profile
# Some versions of Python 2.4 shipped a profiler that had the
# wrong 'c_exception' entry in its dispatch table. Make sure
# we have the right one. (This may put an unnecessary entry
# in the table in earlier versions of Python, but its presence
# shouldn't hurt anything).
try:
dispatch = Profile.dispatch
except AttributeError:
pass
else:
dispatch['c_exception'] = Profile.trace_dispatch_return
prof = Profile()
try:
prof.runcall(_main, parser)
except SConsPrintHelpException, e:
prof.dump_stats(options.profile_file)
raise e
except SystemExit:
pass
示例2: run
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import runcall [as 别名]
def run(self):
self.stats = Stats()
self.init()
self.stats.cpu_speed_before_warmup = get_cpu_speed()
self.warmup()
self.stats.cpu_speed_after_warmup = get_cpu_speed()
if self.profile:
from profile import Profile
profiler = Profile()
profiler.runcall(self.benchmark)
else:
self.benchmark()
self.stats.cpu_speed_after_benchmark = get_cpu_speed()
if self.profile:
import pstats
self.stats.profile_stats = pstats.Stats(profiler)
return self.stats
示例3: __call__
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import runcall [as 别名]
def __call__(self, *args, **kw):
"""Profile a singe call to the function."""
self.ncalls += 1
if self.skip > 0:
self.skip -= 1
self.skipped += 1
return self.fn(*args, **kw)
if FuncProfile.in_profiler:
# handle recursive calls
return self.fn(*args, **kw)
# You cannot reuse the same profiler for many calls and accumulate
# stats that way. :-/
profiler = Profile()
try:
FuncProfile.in_profiler = True
return profiler.runcall(self.fn, *args, **kw)
finally:
FuncProfile.in_profiler = False
self.stats.add(profiler)
if self.immediate:
self.print_stats()
self.reset_stats()
示例4: cmd_func
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import runcall [as 别名]
# Find a function for the command
try:
cmd_func = commands[cmd]['call']
cmd_with_args = lambda: cmd_func(options, args)
except (NameError, KeyError), e:
log.error("No such command '%s'" % cmd)
parser.print_help()
sys.exit(1)
# Fire off the startup event, register for shutdown
plugin_manager.dispatch("startup")
# Execute the chosen command
try:
if options.profile:
from profile import Profile
p = Profile()
p.runcall(cmd_with_args)
p.dump_stats(options.profile)
else:
cmd_with_args()
except CmdException, e:
log.error("Error: %s" % e)
parser.print_help()
sys.exit(1)
plugin_manager.dispatch("shutdown")
示例5: wrapper
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import runcall [as 别名]
def wrapper(*args, **kwargs):
profiler = Profile()
value = profiler.runcall(func, *args, **kwargs)
profiler.dump_stats('/tmp/{}.prof'.format(func.__name__))
return value
示例6: ProgressMsg
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import runcall [as 别名]
# FIXME: there's gonna be a problem if we have a a comma
# in the album name.
for album in po.options.albumName.split(','):
po.options.albumName = album
progress = ProgressMsg(-1, sys.stderr)
pytof = Pytof(po, progress)
if po.options.pyprofile:
# FIXME: factorize me in utils
from profile import Profile
myprofiler = Profile()
myprofiler.create_stats()
myprofiler.runcall(pytof.main)
from tempfile import mktemp
statfile = mktemp()
myprofiler.dump_stats(statfile)
import pstats
p = pstats.Stats(statfile)
os.remove(statfile) # remove temp file
p.strip_dirs()
p.sort_stats('cumulative').print_stats(30)
else:
pytof.main()
示例7: ArgsOptions
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import runcall [as 别名]
try:
ao = ArgsOptions()
options = [ao.options.testModules,
ao.options.profileOut,
ao.options.coverageOutDir]
if ao.options.pyprofile:
# FIXME: factorize me in utils
from profile import Profile
myprofiler = Profile()
myprofiler.create_stats()
myprofiler.runcall(runTests, *options)
statfile = mktemp()
myprofiler.dump_stats(statfile)
import pstats
p = pstats.Stats(statfile)
os.remove(statfile) # remove temp file
p.strip_dirs()
p.sort_stats('cumulative').print_stats(30)
else:
runTests(*options)
# On windows, we make a dummy raw_input so that the
# python terminal does not shut down after exiting