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

Python warmspot.get_stats函数代码示例

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

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



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

示例1: test_location

    def test_location(self):
        def get_printable_location(n):
            return 'GREEN IS %d.' % n
        myjitdriver = JitDriver(greens=['n'], reds=['m'],
                                get_printable_location=get_printable_location)
        def f(n, m):
            while m > 0:
                myjitdriver.can_enter_jit(n=n, m=m)
                myjitdriver.jit_merge_point(n=n, m=m)
                m -= 1

        self.meta_interp(f, [123, 10])
        assert len(get_stats().locations) >= 4
        for loc in get_stats().locations:
            assert loc == (0, 123)
开发者ID:ieure,项目名称:pypy,代码行数:15,代码来源:test_warmspot.py


示例2: test_loop

 def test_loop(self):
     myjitdriver = JitDriver(greens = [], reds = ['x', 'y', 'res'])
     def f(x, y):
         res = 0
         while y > 0:
             myjitdriver.can_enter_jit(x=x, y=y, res=res)
             myjitdriver.jit_merge_point(x=x, y=y, res=res)
             res += x
             y -= 1
         return res
     res = self.meta_interp(f, [6, 7])
     assert res == 42
     self.check_loop_count(1)
     self.check_loops({'guard_true': 1,
                       'int_add': 1, 'int_sub': 1, 'int_gt': 1,
                       'jump': 1})
     if self.basic:
         found = 0
         for op in get_stats().loops[0]._all_operations():
             if op.getopname() == 'guard_true':
                 liveboxes = op.fail_args
                 assert len(liveboxes) == 3
                 for box in liveboxes:
                     assert isinstance(box, history.BoxInt)
                 found += 1
         assert found == 1
开发者ID:enyst,项目名称:plexnet,代码行数:26,代码来源:test_basic.py


示例3: test_list_simple_1

    def test_list_simple_1(self):
        myjitdriver = JitDriver(greens=["foo"], reds=["x", "total"])

        class Foo:
            _immutable_fields_ = ["lst?[*]"]

            def __init__(self, lst):
                self.lst = lst

        def f(a, x):
            lst1 = [0, 0]
            lst1[1] = a
            foo = Foo(lst1)
            total = 0
            while x > 0:
                myjitdriver.jit_merge_point(foo=foo, x=x, total=total)
                # read a quasi-immutable field out of a Constant
                total += foo.lst[1]
                x -= 1
            return total

        #
        res = self.meta_interp(f, [100, 7])
        assert res == 700
        self.check_resops(getarrayitem_gc_pure=0, guard_not_invalidated=2, getarrayitem_gc=0, getfield_gc=0)
        #
        from pypy.jit.metainterp.warmspot import get_stats

        loops = get_stats().loops
        for loop in loops:
            assert len(loop.quasi_immutable_deps) == 1
            assert isinstance(loop.quasi_immutable_deps.keys()[0], QuasiImmut)
开发者ID:are-prabhu,项目名称:pypy,代码行数:32,代码来源:test_quasiimmut.py


示例4: check_loop_count

 def check_loop_count(self, count):
     """NB. This is a hack; use check_tree_loop_count() or
     check_enter_count() for the real thing.
     This counts as 1 every bridge in addition to every loop; and it does
     not count at all the entry bridges from interpreter, although they
     are TreeLoops as well."""
     assert get_stats().compiled_count == count
开发者ID:gorakhargosh,项目名称:pypy,代码行数:7,代码来源:support.py


示例5: test_list_length_1

    def test_list_length_1(self):
        myjitdriver = JitDriver(greens=['foo'], reds=['x', 'total'])

        class Foo:
            _immutable_fields_ = ['lst?[*]']

            def __init__(self, lst):
                self.lst = lst

        class A:
            pass

        def f(a, x):
            lst1 = [0, 0]
            lst1[1] = a
            foo = Foo(lst1)
            total = 0
            while x > 0:
                myjitdriver.jit_merge_point(foo=foo, x=x, total=total)
                # make it a Constant after optimization only
                a = A()
                a.foo = foo
                foo = a.foo
                # read a quasi-immutable field out of it
                total += foo.lst[1]
                # also read the length
                total += len(foo.lst)
                x -= 1
            return total

        #
        res = self.meta_interp(f, [100, 7])
        assert res == 714
        self.check_loops(
            guard_not_invalidated=2,
            getfield_gc=0,
            getarrayitem_gc=0,
            getarrayitem_gc_pure=0,
            arraylen_gc=0,
            everywhere=True)
        #
        from pypy.jit.metainterp.warmspot import get_stats
        loops = get_stats().loops
        for loop in loops:
            assert len(loop.quasi_immutable_deps) == 1
            assert isinstance(loop.quasi_immutable_deps.keys()[0], QuasiImmut)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:46,代码来源:test_quasiimmut.py


示例6: test_interp_single_loop

 def test_interp_single_loop(self):
     myjitdriver = JitDriver(greens = ['i'], reds = ['x', 'y'])
     bytecode = "abcd"
     def f(x, y):
         i = 0
         while i < len(bytecode):
             myjitdriver.jit_merge_point(i=i, x=x, y=y)
             op = bytecode[i]
             if op == 'a':
                 x += y
             elif op == 'b':
                 y -= 1
             elif op == 'c':
                 if y:
                     i = 0
                     myjitdriver.can_enter_jit(i=i, x=x, y=y)
                     continue
             else:
                 x += 1
             i += 1
         return x
     res = self.meta_interp(f, [5, 8])
     assert res == 42
     self.check_trace_count(1)
     # the 'int_eq' and following 'guard' should be constant-folded
     if 'unroll' in self.enable_opts:
         self.check_resops(int_eq=0, guard_true=2, guard_false=0)
     else:
         self.check_resops(int_eq=0, guard_true=1, guard_false=0)
     if self.basic:
         found = 0
         for op in get_stats().loops[0]._all_operations():
             if op.getopname() == 'guard_true':
                 liveboxes = op.getfailargs()
                 assert len(liveboxes) == 2     # x, y (in some order)
                 assert isinstance(liveboxes[0], history.BoxInt)
                 assert isinstance(liveboxes[1], history.BoxInt)
                 found += 1
         if 'unroll' in self.enable_opts:
             assert found == 2
         else:
             assert found == 1
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:42,代码来源:test_loop.py


示例7: test_call_assembler_keep_alive

    def test_call_assembler_keep_alive(self):
        myjitdriver1 = JitDriver(greens=['m'], reds=['n'])
        myjitdriver2 = JitDriver(greens=['m'], reds=['n', 'rec'])
        def h(m, n):
            while True:
                myjitdriver1.can_enter_jit(n=n, m=m)
                myjitdriver1.jit_merge_point(n=n, m=m)
                n = n >> 1
                if n == 0:
                    return 21
        def g(m, rec):
            n = 5
            while n > 0:
                myjitdriver2.can_enter_jit(n=n, m=m, rec=rec)
                myjitdriver2.jit_merge_point(n=n, m=m, rec=rec)
                if rec:
                    h(m, rec)
                n = n - 1
            return 21
        def f(u):
            for i in range(8):
                h(u, 32)  # make a loop and an exit bridge for h(u)
            g(u, 8)       # make a loop for g(u) with a call_assembler
            g(u, 0); g(u+1, 0)     # \
            g(u, 0); g(u+2, 0)     #  \  make more loops for g(u+1) to g(u+4),
            g(u, 0); g(u+3, 0)     #  /  but keeps g(u) alive
            g(u, 0); g(u+4, 0)     # /
            g(u, 8)       # call g(u) again, with its call_assembler to h(u)
            return 42

        res = self.meta_interp(f, [1], loop_longevity=4, inline=True)
        assert res == 42
        self.check_jitcell_token_count(6)
        tokens = [t() for t in get_stats().jitcell_token_wrefs]
        # Some loops have been freed
        assert None in tokens
        # Loop with number 0, h(), has not been freed
        assert 0 in [t.number for t in tokens if t]
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:38,代码来源:test_memmgr.py


示例8: check_aborted_count_at_least

 def check_aborted_count_at_least(self, count):
     assert get_stats().aborted_count >= count
开发者ID:gorakhargosh,项目名称:pypy,代码行数:2,代码来源:support.py


示例9: check_history

 def check_history(self, expected=None, **isns):
     # this can be used after calling meta_interp
     get_stats().check_history(expected, **isns)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:3,代码来源:support.py


示例10: check_jumps

 def check_jumps(self, maxcount):
     assert get_stats().exec_jumps <= maxcount
开发者ID:gorakhargosh,项目名称:pypy,代码行数:2,代码来源:support.py


示例11: check_aborted_count

 def check_aborted_count(self, count):
     assert get_stats().aborted_count == count
开发者ID:gorakhargosh,项目名称:pypy,代码行数:2,代码来源:support.py


示例12: check_enter_count

 def check_enter_count(self, count):
     assert get_stats().enter_count == count
开发者ID:gorakhargosh,项目名称:pypy,代码行数:2,代码来源:support.py


示例13: check_enter_count_at_most

 def check_enter_count_at_most(self, count):
     assert get_stats().enter_count <= count
开发者ID:gorakhargosh,项目名称:pypy,代码行数:2,代码来源:support.py


示例14: check_tree_loop_count

 def check_tree_loop_count(self, count):
     assert len(get_stats().loops) == count
开发者ID:gorakhargosh,项目名称:pypy,代码行数:2,代码来源:support.py


示例15: check_loop_count_at_most

 def check_loop_count_at_most(self, count):
     assert get_stats().compiled_count <= count
开发者ID:gorakhargosh,项目名称:pypy,代码行数:2,代码来源:support.py


示例16: check_target_token_count

 def check_target_token_count(self, count):
     tokens = get_stats().get_all_jitcell_tokens()
     n = sum ([len(t.target_tokens) for t in tokens])
     assert n == count
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:4,代码来源:support.py


示例17: check_loops

 def check_loops(self, expected=None, everywhere=False, **check):
     get_stats().check_loops(expected=expected, everywhere=everywhere,
                             **check)
开发者ID:gorakhargosh,项目名称:pypy,代码行数:3,代码来源:support.py


示例18: check_jitcell_token_count

 def check_jitcell_token_count(self, count): # was check_tree_loop_count
     assert len(get_stats().jitcell_token_wrefs) == count
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:2,代码来源:support.py


示例19: check_max_trace_length

 def check_max_trace_length(self, length):
     for loop in get_stats().loops:
         assert len(loop.operations) <= length + 5 # because we only check once per metainterp bytecode
         for op in loop.operations:
             if op.is_guard() and hasattr(op.getdescr(), '_debug_suboperations'):
                 assert len(op.getdescr()._debug_suboperations) <= length + 5
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:6,代码来源:test_recursive.py


示例20: check_jumps

 def check_jumps(self, maxcount):
     return # FIXME
     assert get_stats().exec_jumps <= maxcount
开发者ID:Debug-Orz,项目名称:Sypy,代码行数:3,代码来源:support.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python warmstate.WarmEnterState类代码示例发布时间:2022-05-27
下一篇:
Python typesystem.deref函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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