當前位置: 首頁>>代碼示例>>Python>>正文


Python memory_profiler.profile方法代碼示例

本文整理匯總了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(): ... 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:29,代碼來源:debug.py

示例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 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:14,代碼來源:debug.py

示例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 
開發者ID:bbfrederick,項目名稱:rapidtide,代碼行數:9,代碼來源:rapidtide2x.py

示例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 
開發者ID:bbfrederick,項目名稱:rapidtide,代碼行數:8,代碼來源:rapidtide2x.py


注:本文中的memory_profiler.profile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。