本文整理汇总了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