本文整理匯總了Python中memory_profiler.profile方法的典型用法代碼示例。如果您正苦於以下問題:Python memory_profiler.profile方法的具體用法?Python memory_profiler.profile怎麽用?Python memory_profiler.profile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類memory_profiler
的用法示例。
在下文中一共展示了memory_profiler.profile方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: runprofilerandshow
# 需要導入模塊: import memory_profiler [as 別名]
# 或者: from memory_profiler import profile [as 別名]
def runprofilerandshow(funcname, profilepath, argv='', *args, **kwargs):
'''
Run a functions profiler and show it in a GUI visualisation using RunSnakeRun
Note: can also use calibration for more exact results
'''
functionprofiler.runprofile(funcname+'(\''+argv+'\')', profilepath, *args, **kwargs)
print 'Showing profile (windows should open in the background)'; sys.stdout.flush();
functionprofiler.browseprofilegui(profilepath)
#### DECORATOR FUNCTIONS ####
#############################
# @profile: use profilehooks to profile functions
# @profileit: profile using python's profile (works with threads)
# @showprofile: show the functions profile in a nice GUI using RunSnakeRun (alternative: using the generated profile log files you can use pyprof2calltree and kcachegrind to get a lot more informations and interactive call graph)
# @memorytrack: use Pympler to track and show memory usage (only console, no GUI)
#@callgraph: save the call graph in text format and image (if GraphViz is available, more specifically the dot program)
#@profile_linebyline: profile a function with line by line CPU consumption (using line_profiler, need to install it because it is compiled in C)
#@memoryprofile_linebyline: memory profile a function with line by line memory consumption (using memory_profiler, needs psutils on Windows)
# eg:
# @showprofile
# @profileit
# def func(): ...
示例2: testcaptcha
# 需要導入模塊: import memory_profiler [as 別名]
# 或者: from memory_profiler import profile [as 別名]
def testcaptcha():
import captchagenerator
captcha = captchagenerator.CaptchaGenerator(True, True, debugPng=True, debug=False, nbElem=10, modelsPath='bammodels', windowWidth='320', windowHeight='240')
#captcha.renderCaptcha('solmasks', 'solmasks')
captcha.renderCaptchaMulti(4, 'solmasks', 'solmasks')
#time.sleep(20)
#@memoryprofile_linebyline
#@profile_linebyline
示例3: conditionalprofile
# 需要導入模塊: import memory_profiler [as 別名]
# 或者: from memory_profiler import profile [as 別名]
def conditionalprofile():
def resdec(f):
if memprofilerexists:
return profile(f)
return f
return resdec
示例4: addmemprofiling
# 需要導入模塊: import memory_profiler [as 別名]
# 或者: from memory_profiler import profile [as 別名]
def addmemprofiling(thefunc, memprofile, memfile, themessage):
if memprofile:
return profile(thefunc, precision=2)
else:
tide_util.logmem(themessage, file=memfile)
return thefunc