本文整理汇总了Python中profile.Profile.dump_stats方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.dump_stats方法的具体用法?Python Profile.dump_stats怎么用?Python Profile.dump_stats使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类profile.Profile
的用法示例。
在下文中一共展示了Profile.dump_stats方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _exec_main
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import dump_stats [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: cmd_func
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import dump_stats [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")
示例3: wrapper
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import dump_stats [as 别名]
def wrapper(*args, **kwargs):
profiler = Profile()
value = profiler.runcall(func, *args, **kwargs)
profiler.dump_stats('/tmp/{}.prof'.format(func.__name__))
return value
示例4: ProgressMsg
# 需要导入模块: from profile import Profile [as 别名]
# 或者: from profile.Profile import dump_stats [as 别名]
# 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()