• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python yappi.get_func_stats函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中yappi.get_func_stats函数的典型用法代码示例。如果您正苦于以下问题:Python get_func_stats函数的具体用法?Python get_func_stats怎么用?Python get_func_stats使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_func_stats函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_profile_single_context

    def test_profile_single_context(self):
        
        def id_callback():
            return self.callback_count
        def a():
            pass

        self.callback_count = 1
        yappi.set_context_id_callback(id_callback)
        yappi.start(profile_threads=False)
        a() # context-id:1
        self.callback_count = 2
        a() # context-id:2
        stats = yappi.get_func_stats()
        fsa = utils.find_stat_by_name(stats, "a")
        self.assertEqual(fsa.ncall, 1)
        yappi.stop()
        yappi.clear_stats()
        
        self.callback_count = 1
        yappi.start() # profile_threads=True
        a() # context-id:1
        self.callback_count = 2
        a() # context-id:2
        stats = yappi.get_func_stats()
        fsa = utils.find_stat_by_name(stats, "a")
        self.assertEqual(fsa.ncall, 2)
开发者ID:sumerc,项目名称:yappi,代码行数:27,代码来源:test_hooks.py


示例2: test_merge_multithreaded_stats

 def test_merge_multithreaded_stats(self):
     import threading
     import _yappi
     timings = {"a_1":2, "b_1":1}
     _yappi._set_test_timings(timings)
     def a(): pass
     def b(): pass
     yappi.start()
     t = threading.Thread(target=a)
     t.start()
     t.join()
     t = threading.Thread(target=b)
     t.start()
     t.join()
     yappi.get_func_stats().save("ystats1.ys")
     yappi.clear_stats()
     _yappi._set_test_timings(timings)
     self.assertEqual(len(yappi.get_func_stats()), 0)
     self.assertEqual(len(yappi.get_thread_stats()), 1)
     t = threading.Thread(target=a)
     t.start()
     t.join()
     
     self.assertEqual(_yappi._get_start_flags()["profile_builtins"], 0)
     self.assertEqual(_yappi._get_start_flags()["profile_multithread"], 1)
     yappi.get_func_stats().save("ystats2.ys")
    
     stats = yappi.YFuncStats(["ystats1.ys", "ystats2.ys",])
     fsa = utils.find_stat_by_name(stats, "a")
     fsb = utils.find_stat_by_name(stats, "b")
     self.assertEqual(fsa.ncall, 2)
     self.assertEqual(fsb.ncall, 1)
     self.assertEqual(fsa.tsub, fsa.ttot, 4)
     self.assertEqual(fsb.tsub, fsb.ttot, 1)
开发者ID:pombredanne,项目名称:yappi,代码行数:34,代码来源:test_functionality.py


示例3: stats_string

 def stats_string(self, id):
     output = StringIO.StringIO()
     yappi.get_func_stats().print_all(out=output)
     m = ProfilerResponse()
     m.id = id
     m.ystats_string = output.getvalue()
     self.writer.addCommand(m)
开发者ID:machao657,项目名称:intellij-community,代码行数:7,代码来源:run_profiler.py


示例4: test_filter

    def test_filter(self):
        def a(): pass
        def b(): a()
        def c(): b()

        _TCOUNT = 5

        ts = []
        yappi.start()
        for i in range(_TCOUNT):
            t = threading.Thread(target=c)
            t.start()
            ts.append(t)

        for t in ts:
            t.join()

        yappi.stop()

        fstats = yappi.get_func_stats(filter={"ctx_id":9})
        self.assertTrue(fstats.empty())
        fstats = yappi.get_func_stats(filter={"ctx_id":0, "name":"c"}) # main thread
        self.assertTrue(fstats.empty())

        for i in range(1, _TCOUNT):
            fstats = yappi.get_func_stats(filter={"ctx_id":i, "name":"a", 
                "ncall":1})
            self.assertEqual(fstats.pop().ncall, 1)
            fstats = yappi.get_func_stats(filter={"ctx_id":i, "name":"b"})
            self.assertEqual(fstats.pop().ncall, 1)
            fstats = yappi.get_func_stats(filter={"ctx_id":i, "name":"c"})
            self.assertEqual(fstats.pop().ncall, 1)
开发者ID:sumerc,项目名称:yappi,代码行数:32,代码来源:test_functionality.py


示例5: stop

    def stop(self):
        self._running = False
        self._tick_timer.cancel()
        self._stop_time = time.time()

        if self._app.args.yappi and USE_YAPPI:
            yappi.get_func_stats().print_all()
开发者ID:tibbon,项目名称:firemix,代码行数:7,代码来源:mixer.py


示例6: wrapped

 def wrapped(*args, **kwargs):
     yappi.start()
     result = func(*args, **kwargs)
     yappi.stop()
     prof_file = "%s.%s" % (func.__name__, time.time())
     #prof_file = "callgrind.a.1"
     yappi.get_func_stats().save(prof_file, "ystat")
     return result
开发者ID:pombredanne,项目名称:yappi,代码行数:8,代码来源:save_stats.py


示例7: on_close

 def on_close(self, e):
     self.netcontroller.running = False
     #self.net_thread.quit()
     if self.args.profile:
         try:
             import yappi
             yappi.get_func_stats().print_all()
         except ImportError:
             pass
开发者ID:Openlights,项目名称:firesim,代码行数:9,代码来源:firesimgui.py


示例8: yappi_prof_call

def yappi_prof_call(func, *args):
    '''
        https://code.google.com/p/yappi/wiki/usageyappi_v092
    '''
    import yappi
    yappi.start()
    result = func(*args)
    yappi.get_func_stats().print_all()
    yappi.get_thread_stats().print_all()
    return result
开发者ID:aiex,项目名称:requestspool,代码行数:10,代码来源:geventwsgi.py


示例9: update

def update():

	computer.run( clock.value )

	if io.hasExited:
	 
		clock.stop()
		print( 'See you later!' )

		yappi.get_func_stats().print_all()
开发者ID:JetStarBlues,项目名称:Nand-2-Tetris,代码行数:10,代码来源:demo_profiled.py


示例10: cmd_stop

    def cmd_stop(self, args):
        """stop profiling"""
        print "Profile results:"
        import yappi  # We do the import here so that we won't barf if run normally and yappi not available

        yappi.get_func_stats().print_all(
            columns={0: ("name", 50), 1: ("ncall", 5), 2: ("tsub", 8), 3: ("ttot", 8), 4: ("tavg", 8)}
        )
        yappi.get_thread_stats().print_all()
        yappi.stop()
开发者ID:StudentCopters,项目名称:MAVProxy,代码行数:10,代码来源:mavproxy_profile.py


示例11: clusterizacao

def clusterizacao(request, debate_id, qtdGrupos=3):
	
## COLOCAR COMO OPÇÃO PARA O USUÁRIO SE ELE QUER AGRUPAR 
## PELO POSICIONAMENTO INICIAL OU FINAL 
	print "view-clusterização em funcionamento!!!"
	inicio = datetime.now()
	print inicio,"view clusterizacao"
	
	yappi.set_clock_type('cpu')
	yappi.start(builtins=True)
	start = time.time()
	
	auxResult = clusterArgInicial(debate_id)
	
	duration = time.time() - start
	stats = yappi.get_func_stats()
	stats.save('clusterArgInicial.out', type = 'callgrind')
	
	
	
	tese = auxResult[5]
	
	
	yappi.set_clock_type('cpu')
	yappi.start(builtins=True)
	start = time.time()
	
#	resultado = gruposArgumentacao(auxResult, qtdeGrupos=3, LSA=True, Normalizacao=True)
# 	resultado = gruposArgumentacao(auxResult, qtdeGrupos=4, LSA=True, Normalizacao=True)
# 	resultado = gruposArgumentacao(auxResult, qtdeGrupos=5, LSA=True, Normalizacao=True)
# 	resultado = gruposArgumentacao(auxResult, qtdeGrupos=6, LSA=True, Normalizacao=True)
	
	resultado = gruposArgumentacao(auxResult, qtdeGrupos=int(qtdGrupos), LSA=None, Normalizacao=True)
	
	duration = time.time() - start
	stats = yappi.get_func_stats()
	stats.save('gruposArgumentacao.out', type = 'callgrind')
	
	grupo1 = resultado[0]
	grupo2 = resultado[1]
	grupo3 = resultado[2]
	grupo4 = resultado[3]
	grupo5 = resultado[4]
	grupo6 = resultado[5]

	
	
	
	context = RequestContext(request,{'results' : [grupo1,grupo2,grupo3,grupo4,\
										len(grupo1),len(grupo2),len(grupo3),len(grupo4), tese, \
										grupo5, len(grupo5), grupo6, len(grupo6)],
										'grupo' : Grupo.objects.filter(idgrupo=1064)[0]})
	
	return render(request, 'clusterizacao.html',context)
开发者ID:SabrinaPanceri,项目名称:alpes_v1,代码行数:54,代码来源:views.py


示例12: main

def main():
    print('Main TID: {}'.format(gettid()))
    args = Bunch(channel=None,
                 devices=[],
                 generate=False,
                 ui='main.ui')
    yappi.start()
    exit_value = epyqlib.__main__.main(args=args)
    yappi.stop()
    yappi.get_func_stats().save('yappi.stats', type='pstat')
    yappi.get_thread_stats().print_all()
    return exit_value
开发者ID:altendky,项目名称:st,代码行数:12,代码来源:profile_yappi.py


示例13: run

def run():
    host = "http://localhost:8080"
    urls = ["/client.py", "/echo_server.py"]
    global all_task
    all_task = len(urls)

    yappi.start()
    for url in urls:
        fetch(host + url)
        print "fetch url:", url

    yappi.get_func_stats().print_all()
    IOLoop.instance().start()
开发者ID:win0x86,项目名称:Lab,代码行数:13,代码来源:client.py


示例14: test_no_stats_different_clock_type_load

 def test_no_stats_different_clock_type_load(self):
     def a(): pass
     yappi.start()
     a()
     yappi.stop()
     yappi.get_func_stats().save("ystats1.ys")
     yappi.clear_stats()
     yappi.set_clock_type("WALL")
     yappi.start()
     yappi.stop()
     stats = yappi.get_func_stats().add("ystats1.ys")
     fsa = utils.find_stat_by_name(stats, 'a')
     self.assertTrue(fsa is not None)
开发者ID:pombredanne,项目名称:yappi,代码行数:13,代码来源:test_functionality.py


示例15: tearDown

 def tearDown(self):
     fstats = yappi.get_func_stats()
     if not fstats._debug_check_sanity():
         sys.stdout.write("ERR: Duplicates found in Func stats\r\n")
         
         fstats.debug_print()
     for fstat in fstats:
         if not fstat.children._debug_check_sanity():
             sys.stdout.write("ERR: Duplicates found in ChildFunc stats\r\n")
             fstat.children.print_all()
     tstats = yappi.get_func_stats()
     if not tstats._debug_check_sanity():
         sys.stdout.write("ERR: Duplicates found in Thread stats\r\n")
         tstats.print_all()
开发者ID:pombredanne,项目名称:yappi,代码行数:14,代码来源:utils.py


示例16: main

def main(argv):
    parser = argparse.ArgumentParser(description='Convert a FASTA and QUAL pair of files into a FASQ file')
    parser.add_argument('fasta_filename',
                        help='the FASTA format input file path')
    parser.add_argument('qual_filename',
                        help='the QUAL format input file path')
    parser.add_argument('-q', action='store_true',
                        help="run quietly")
    parser.add_argument('-d', action='store_true',
                        help="print diagnostics to stderr")
    parser.add_argument('-z','--gzip', action='store_true',
                       help='input & output are gzipped')
    parser.add_argument('-p', '--profile', action='store_true',
                        help="profile this execution")
    parser.add_argument('-o', '--output',
                        default=sys.stdout, type=argparse.FileType('w'),
                        help='the output FASTQ file path')
    args = parser.parse_args()

    global debug_flag
    debug_flag = args.d

    debug_flag and sys.stderr.write("%r\n" % args)

    if args.profile:
        import yappi # https://code.google.com/p/yappi/wiki/apiyappi
        yappi.start(builtins=True)

    if args.gzip:
        import gzip
        fasta = gzip.open(args.fasta_filename)
        qual = gzip.open(args.qual_filename)
        outf = gzip.GzipFile(fileobj=args.output, mode='wb')
    else:
        fasta = open(args.fasta_filename)
        qual = open(args.qual_filename)
        outf = args.output

    # alphabet irrelevant (and makes it slow) records = PairedFastaQualIterator(fasta, qual, alphabet=IUPAC.ambiguous_dna)
    records = PairedFastaQualIterator(fasta, qual)
    count = SeqIO.write(records, outf, "fastq")
    outf.close()

    if args.profile:
        yappi.get_thread_stats().print_all(sys.stderr)
        yappi.get_func_stats().sort("subtime").print_all(sys.stderr)

    print("Converted %i records" % count)
开发者ID:mattsoulanille,项目名称:Sprock,代码行数:48,代码来源:fandq2fq.py


示例17: test_basic

    def test_basic(self):
        yappi.set_clock_type('wall')
        def dummy():
            pass
        def a():
            time.sleep(0.2)
        class Worker1(threading.Thread):
            def a(self):
                time.sleep(0.3)
            def run(self):
                self.a()
        yappi.start(builtins=False, profile_threads=True)

        c = Worker1()
        c.start()
        c.join()
        a()
        stats = yappi.get_func_stats()
        fsa1 = utils.find_stat_by_name(stats, 'Worker1.a')
        fsa2 = utils.find_stat_by_name(stats, 'a')
        self.assertTrue(fsa1 is not None)
        self.assertTrue(fsa2 is not None)
        self.assertTrue(fsa1.ttot > 0.2)
        self.assertTrue(fsa2.ttot > 0.1)
        tstats = yappi.get_thread_stats()
        self.assertEqual(len(tstats), 2)
        tsa = utils.find_stat_by_name(tstats, 'Worker1')
        tsm = utils.find_stat_by_name(tstats, '_MainThread')
        dummy() # call dummy to force ctx name to be retrieved again.
        self.assertTrue(tsa is not None)
        # TODO: I put dummy() to fix below, remove the comments after a while.
        self.assertTrue( # FIX: I see this fails sometimes?
            tsm is not None, 
            'Could not find "_MainThread". Found: %s' % (', '.join(utils.get_stat_names(tstats)))) 
开发者ID:sumerc,项目名称:yappi,代码行数:34,代码来源:test_functionality.py


示例18: test_print_formatting

    def test_print_formatting(self):
        def a():
            pass

        def b():
            a()

        func_cols = {1: ("name", 48), 0: ("ncall", 5), 2: ("tsub", 8)}
        thread_cols = {1: ("name", 48), 0: ("ttot", 8)}

        yappi.start()
        a()
        b()
        yappi.stop()
        fs = yappi.get_func_stats()
        cs = fs[1].children
        ts = yappi.get_thread_stats()
        # fs.print_all(out=sys.stderr, columns={1:("name", 70), })
        # cs.print_all(out=sys.stderr, columns=func_cols)
        # ts.print_all(out=sys.stderr, columns=thread_cols)
        # cs.print_all(out=sys.stderr, columns={})

        self.assertRaises(yappi.YappiError, fs.print_all, columns={1: ("namee", 9)})
        self.assertRaises(yappi.YappiError, cs.print_all, columns={1: ("dd", 0)})
        self.assertRaises(yappi.YappiError, ts.print_all, columns={1: ("tidd", 0)})
开发者ID:smeder,项目名称:GreenletProfiler,代码行数:25,代码来源:test_functionality.py


示例19: test_singlethread_profiling

    def test_singlethread_profiling(self):
        yappi.set_clock_type("wall")

        def a():
            time.sleep(0.2)

        class Worker1(threading.Thread):
            def a(self):
                time.sleep(0.3)

            def run(self):
                self.a()

        yappi.start(profile_threads=False)

        c = Worker1()
        c.start()
        c.join()
        a()
        stats = yappi.get_func_stats()
        fsa1 = utils.find_stat_by_name(stats, "Worker1.a")
        fsa2 = utils.find_stat_by_name(stats, "a")
        self.assertTrue(fsa1 is None)
        self.assertTrue(fsa2 is not None)
        self.assertTrue(fsa2.ttot > 0.1)
开发者ID:smeder,项目名称:GreenletProfiler,代码行数:25,代码来源:test_functionality.py


示例20: yappi_logger

def yappi_logger(path):
    while True:
        time.sleep(60)
        yf = yappi.get_func_stats()
        they = sorted(yf, key=lambda x: x.ttot, reverse=True)
        #they = sorted(filter(lambda x: not x.builtin, yf), key=lambda x: x.ttot, reverse=True)
        opath = path + time.strftime('%Y%m%d_%H%M%S') + '.txt'
        with open(opath, 'wb') as fout:
            if True:
                sum_func_time = sum(map(lambda x: x.tsub, they))
                fout.write('total {} seconds function time\n'.format(sum_func_time))
                fout.write('func+subs\tfunc\ttot/call\tncalls\n')
                for x in they:
                    fout.write(_yfstr(x))
            else:
                yf.print_all(
                    out=fout,
                    columns={
                        0:("name",80),
                        1:("ncall", 9),
                        2:("tsub", 8),
                        3:("ttot", 8),
                        4:("tavg",8),
                    }
                )
        sys.stderr.write('wrote profiling\n{}\n'.format(opath))
        if os.path.exists('bobreak'):
            pdb.set_trace()
开发者ID:diffeo,项目名称:coordinate,代码行数:28,代码来源:run.py



注:本文中的yappi.get_func_stats函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python yappi.get_thread_stats函数代码示例发布时间:2022-05-26
下一篇:
Python yappi.clear_stats函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap