本文整理匯總了Python中_lsprof.Profiler方法的典型用法代碼示例。如果您正苦於以下問題:Python _lsprof.Profiler方法的具體用法?Python _lsprof.Profiler怎麽用?Python _lsprof.Profiler使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類_lsprof
的用法示例。
在下文中一共展示了_lsprof.Profiler方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_bad_counter_during_dealloc
# 需要導入模塊: import _lsprof [as 別名]
# 或者: from _lsprof import Profiler [as 別名]
def test_bad_counter_during_dealloc(self):
import _lsprof
# Must use a file as StringIO doesn't trigger the bug.
orig_stderr = sys.stderr
try:
with open(TESTFN, 'w') as file:
sys.stderr = file
try:
obj = _lsprof.Profiler(lambda: int)
obj.enable()
obj = _lsprof.Profiler(1)
obj.disable()
obj.clear()
finally:
sys.stderr = orig_stderr
finally:
unlink(TESTFN)
示例2: help
# 需要導入模塊: import _lsprof [as 別名]
# 或者: from _lsprof import Profiler [as 別名]
def help():
print "Documentation for the profile/cProfile modules can be found "
print "in the Python Library Reference, section 'The Python Profiler'."
# ____________________________________________________________
示例3: test_bad_counter_during_dealloc
# 需要導入模塊: import _lsprof [as 別名]
# 或者: from _lsprof import Profiler [as 別名]
def test_bad_counter_during_dealloc(self):
import _lsprof
# Must use a file as StringIO doesn't trigger the bug.
sys.stderr = open(TESTFN, 'w')
try:
obj = _lsprof.Profiler(lambda: int)
obj.enable()
obj = _lsprof.Profiler(1)
obj.disable()
finally:
sys.stderr = sys.__stderr__
unlink(TESTFN)
示例4: test_bad_counter_during_dealloc
# 需要導入模塊: import _lsprof [as 別名]
# 或者: from _lsprof import Profiler [as 別名]
def test_bad_counter_during_dealloc():
import _lsprof
# Must use a file as StringIO doesn't trigger the bug.
sys.stderr = open(test.test_support.TESTFN, 'w')
try:
obj = _lsprof.Profiler(lambda: int)
obj.enable()
obj = _lsprof.Profiler(1)
obj.disable()
finally:
sys.stderr = sys.__stderr__
test.test_support.unlink(test.test_support.TESTFN)
示例5: profile
# 需要導入模塊: import _lsprof [as 別名]
# 或者: from _lsprof import Profiler [as 別名]
def profile(f, *args, **kwds):
"""XXX docstring"""
p = Profiler()
p.enable(subcalls=True, builtins=True)
try:
f(*args, **kwds)
finally:
p.disable()
return Stats(p.getstats())