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


Python stats.strip_dirs方法代碼示例

本文整理匯總了Python中hotshot.stats.strip_dirs方法的典型用法代碼示例。如果您正苦於以下問題:Python stats.strip_dirs方法的具體用法?Python stats.strip_dirs怎麽用?Python stats.strip_dirs使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在hotshot.stats的用法示例。


在下文中一共展示了stats.strip_dirs方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: print_stats

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def print_stats(self):
        """Print profile information to sys.stdout."""
        stats = self.stats
        if self.filename:
            stats.dump_stats(self.filename)
        if self.stdout:
            funcname = self.fn.__name__
            filename = self.fn.__code__.co_filename
            lineno = self.fn.__code__.co_firstlineno
            print("")
            print("*** PROFILER RESULTS ***")
            print("%s (%s:%s)" % (funcname, filename, lineno))
            if self.skipped:
                skipped = " (%d calls not profiled)" % self.skipped
            else:
                skipped = ""
            print("function called %d times%s" % (self.ncalls, skipped))
            print("")
            if not self.dirs:
                stats.strip_dirs()
            stats.sort_stats(*self.sort)
            stats.print_stats(self.entries) 
開發者ID:Soft8Soft,項目名稱:verge3d-blender-addon,代碼行數:24,代碼來源:profilehooks.py

示例2: main

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def main(logfile):
    p = hotshot.Profile(logfile)
    benchtime, stones = p.runcall(test.pystone.pystones)
    p.close()

    print "Pystone(%s) time for %d passes = %g" % \
          (test.pystone.__version__, test.pystone.LOOPS, benchtime)
    print "This machine benchmarks at %g pystones/second" % stones

    stats = hotshot.stats.load(logfile)
    stats.strip_dirs()
    stats.sort_stats('time', 'calls')
    try:
        stats.print_stats(20)
    except IOError, e:
        if e.errno != errno.EPIPE:
            raise 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:stones.py

示例3: profile

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def profile(func, *args, **kwargs):
    import hotshot.stats

    prf = hotshot.Profile('mystats.profile')
    print("Start")
    r = prf.runcall(func, *args, **kwargs)
    print("Finished")
    prf.close()
    print("Loading profile")
    stats = hotshot.stats.load('mystats.profile')
    print("done")
    stats.strip_dirs()
    stats.sort_stats('time', 'calls')
    stats.print_stats(100)
    stats.print_callers(100)
    return r 
開發者ID:GenealogyCollective,項目名稱:gprime,代碼行數:18,代碼來源:debug.py

示例4: print_stats

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def print_stats(self):
        """Print profile information to sys.stdout."""
        funcname = self.fn.__name__
        filename = self.fn.__code__.co_filename
        lineno = self.fn.__code__.co_firstlineno
        print("")
        print("*** PROFILER RESULTS ***")
        print("%s (%s:%s)" % (funcname, filename, lineno))
        if self.skipped:
            skipped = "(%d calls not profiled)" % self.skipped
        else:
            skipped = ""
        print("function called %d times%s" % (self.ncalls, skipped))
        print("")
        stats = self.stats
        if self.filename:
            stats.dump_stats(self.filename)
        if not self.dirs:
            stats.strip_dirs()
        stats.sort_stats(*self.sort)
        stats.print_stats(self.entries) 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:23,代碼來源:profilehooks.py

示例5: runMain

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def runMain(main, options, args):
    if options.profile:
        if True:
            import hotshot
            profile = hotshot.Profile(options.profile)
            profile.runcall(main, options, args)
            profile.close()
            import hotshot.stats
            stats = hotshot.stats.load(options.profile)
        else:
            import profile
            profile.run('main(options, args)', options.profile)
            import pstats
            stats = pstats.Stats(options.profile)
        stats.strip_dirs()
        stats.sort_stats('time', 'calls')
        stats.print_stats(20)
    elif options.psyco:
        import psyco
        psyco.full()
        status = main(options, args)
    else:
        status = main(options, args)
    return status 
開發者ID:sequitur-g2p,項目名稱:sequitur-g2p,代碼行數:26,代碼來源:tool.py

示例6: profiled

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def profiled(f, outputFile):
    def _(*args, **kwargs):
        if sys.version_info[0:2] != (2, 4):
            import profile
            prof = profile.Profile()
            try:
                result = prof.runcall(f, *args, **kwargs)
                prof.dump_stats(outputFile)
            except SystemExit:
                pass
            prof.print_stats()
            return result
        else: # use hotshot, profile is broken in 2.4
            import hotshot.stats
            prof = hotshot.Profile(outputFile)
            try:
                return prof.runcall(f, *args, **kwargs)
            finally:
                stats = hotshot.stats.load(outputFile)
                stats.strip_dirs()
                stats.sort_stats('cum')   # 'time'
                stats.print_stats(100)
    return _ 
開發者ID:kuri65536,項目名稱:python-for-android,代碼行數:25,代碼來源:util.py

示例7: prof_main

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def prof_main(argv):
    import hotshot, hotshot.stats
    def usage():
        print(('usage: %s module.function [args ...]' % argv[0]))
        return 100
    args = argv[1:]
    if len(args) < 1: return usage()
    name = args.pop(0)
    prof = name+'.prof'
    i = name.rindex('.')
    (modname, funcname) = (name[:i], name[i+1:])
    module = __import__(modname, fromlist=1)
    func = getattr(module, funcname)
    if args:
        args.insert(0, argv[0])
        prof = hotshot.Profile(prof)
        prof.runcall(lambda : func(args))
        prof.close()
    else:
        stats = hotshot.stats.load(prof)
        stats.strip_dirs()
        stats.sort_stats('time', 'calls')
        stats.print_stats(1000)
    return 
開發者ID:gwk,項目名稱:pdfminer3,代碼行數:26,代碼來源:prof.py

示例8: print_stats

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def print_stats(self):
        """Print profile information to sys.stdout."""
        funcname = self.fn.__name__
        filename = self.fn.func_code.co_filename
        lineno = self.fn.func_code.co_firstlineno
        print
        print "*** PROFILER RESULTS ***"
        print "%s (%s:%s)" % (funcname, filename, lineno)
        print "function called %d times" % self.ncalls,
        if self.skipped:
            print "(%d calls not profiled)" % self.skipped
        else:
            print
        print
        stats = self.stats
        if self.filename:
            stats.dump_stats(self.filename)
        if not self.dirs:
            stats.strip_dirs()
        stats.sort_stats(*self.sort)
        stats.print_stats(self.entries) 
開發者ID:Tautulli,項目名稱:Tautulli,代碼行數:23,代碼來源:profilehooks.py

示例9: runTest

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def runTest(self):
        self.prof = hotshot.Profile('%s.prof' % self.__class__.__name__)
        self.prof.start()
        for i in range(self.iterations):
            if hasattr(self, 'performanceSample'):
                self.display = True
                self.performanceSample()
        self.prof.stop()
        self.prof.close()
        if self.display:
            print('>>> %s (%d iterations) ' % (self.__class__.__name__,
                    self.iterations))
            stats = hotshot.stats.load('%s.prof' % self.__class__.__name__)
            #stats.strip_dirs()
            stats.sort_stats('time', 'calls')
            stats.print_stats(50)

        if not self.save:
            os.unlink('%s.prof' % self.__class__.__name__) 
開發者ID:binhex,項目名稱:moviegrabber,代碼行數:21,代碼來源:Performance.py

示例10: __call__

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def __call__(self, environ, start_response):
        catch_response = []
        body = []
        def replace_start_response(status, headers, exc_info=None):
            catch_response.extend([status, headers])
            start_response(status, headers, exc_info)
            return body.append
        def run_app():
            app_iter = self.app(environ, replace_start_response)
            try:
                body.extend(app_iter)
            finally:
                if hasattr(app_iter, 'close'):
                    app_iter.close()
        self.lock.acquire()
        try:
            prof = hotshot.Profile(self.log_filename)
            prof.addinfo('URL', environ.get('PATH_INFO', ''))
            try:
                prof.runcall(run_app)
            finally:
                prof.close()
            body = ''.join(body)
            headers = catch_response[1]
            content_type = response.header_value(headers, 'content-type')
            if content_type is None or not content_type.startswith('text/html'):
                # We can't add info to non-HTML output
                return [body]
            stats = hotshot.stats.load(self.log_filename)
            stats.strip_dirs()
            stats.sort_stats('time', 'calls')
            output = capture_output(stats.print_stats, self.limit)
            output_callers = capture_output(
                stats.print_callers, self.limit)
            body += '<pre style="%s">%s\n%s</pre>' % (
                self.style, cgi.escape(output), cgi.escape(output_callers))
            return [body]
        finally:
            self.lock.release() 
開發者ID:linuxscout,項目名稱:mishkal,代碼行數:41,代碼來源:profile.py

示例11: atexit

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def atexit(self):
            """Stop profiling and print profile information to sys.stderr.

            This function is registered as an atexit hook.
            """
            self.profiler.close()
            funcname = self.fn.__name__
            filename = self.fn.__code__.co_filename
            lineno = self.fn.__code__.co_firstlineno
            print("")
            print("*** PROFILER RESULTS ***")
            print("%s (%s:%s)" % (funcname, filename, lineno))
            if self.skipped:
                skipped = "(%d calls not profiled)" % self.skipped
            else:
                skipped = ""
            print("function called %d times%s" % (self.ncalls, skipped))
            print("")
            stats = hotshot.stats.load(self.logfilename)
            # hotshot.stats.load takes ages, and the .prof file eats megabytes, but
            # a saved stats object is small and fast
            if self.filename:
                stats.dump_stats(self.filename)
            # it is best to save before strip_dirs
            stats.strip_dirs()
            stats.sort_stats('cumulative', 'time', 'calls')
            stats.print_stats(40) 
開發者ID:lrq3000,項目名稱:pyFileFixity,代碼行數:29,代碼來源:profilehooks.py

示例12: profile

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def profile(func, *args, **kwargs):
    prof = hotshot.Profile("object.prof")
    prof.runcall(func, *args, **kwargs)
    prof.close()
    stats = hotshot.stats.load("object.prof")
    stats.strip_dirs()
    stats.sort_stats('time', 'calls')
    stats.print_stats(30)
    os.remove('object.prof') 
開發者ID:maximkulkin,項目名稱:lollipop,代碼行數:11,代碼來源:benchmark.py

示例13: profile_tests

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def profile_tests(which=None):
    print 'Profiling...'
    print
    import hotshot, hotshot.stats
    profile_data = 'template.prof'
    profile = hotshot.Profile(profile_data)
    profile.runcall(run_tests, which=which, number=1, compare=False)
    stats = hotshot.stats.load(profile_data)
    stats.strip_dirs()
    stats.sort_stats('time', 'calls')
    print
    stats.print_stats()
    print 'Profile data written to %s' % profile_data 
開發者ID:youtube,項目名稱:spitfire,代碼行數:15,代碼來源:render_benchmark.py

示例14: OtherTest

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def OtherTest():
	print "Doing hotshot test"
	import hotshot
	import hotshot.stats
	prof = hotshot.Profile("stones.prof")
	benchtime = prof.runcall(Tester)
	stats = hotshot.stats.load("stones.prof")
	stats.strip_dirs()
	stats.sort_stats('time', 'calls')
	stats.print_stats(20) 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:12,代碼來源:bench.py

示例15: ThirdTest

# 需要導入模塊: from hotshot import stats [as 別名]
# 或者: from hotshot.stats import strip_dirs [as 別名]
def ThirdTest():
	print "Doing old profiler test"
	import profile
	import pstats
	
	benchtime = profile.run('Tester()', 'fooprof')
	stats = pstats.Stats('fooprof')
	stats.strip_dirs()
	stats.sort_stats('time', 'calls')
	stats.print_stats(20) 
開發者ID:kenorb-contrib,項目名稱:BitTorrent,代碼行數:12,代碼來源:bench.py


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