当前位置: 首页>>代码示例>>Python>>正文


Python WarmEnterState._make_jitcell_getter_default方法代码示例

本文整理汇总了Python中pypy.jit.metainterp.warmstate.WarmEnterState._make_jitcell_getter_default方法的典型用法代码示例。如果您正苦于以下问题:Python WarmEnterState._make_jitcell_getter_default方法的具体用法?Python WarmEnterState._make_jitcell_getter_default怎么用?Python WarmEnterState._make_jitcell_getter_default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pypy.jit.metainterp.warmstate.WarmEnterState的用法示例。


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

示例1: test_cleanup_jitcell_dict

# 需要导入模块: from pypy.jit.metainterp.warmstate import WarmEnterState [as 别名]
# 或者: from pypy.jit.metainterp.warmstate.WarmEnterState import _make_jitcell_getter_default [as 别名]
def test_cleanup_jitcell_dict():
    class FakeJitDriverSD:
        _green_args_spec = [lltype.Signed]

    #
    # Test creating tons of jitcells that remain at 0
    warmstate = WarmEnterState(None, FakeJitDriverSD())
    get_jitcell = warmstate._make_jitcell_getter_default()
    cell1 = get_jitcell(True, -1)
    assert len(warmstate._jitcell_dict) == 1
    #
    for i in range(1, 20005):
        get_jitcell(True, i)  # should trigger a clean-up at 20001
        assert len(warmstate._jitcell_dict) == (i % 20000) + 1
    #
    # Same test, with one jitcell that has a counter of BASE instead of 0
    warmstate = WarmEnterState(None, FakeJitDriverSD())
    get_jitcell = warmstate._make_jitcell_getter_default()
    cell2 = get_jitcell(True, -2)
    cell2.counter = BASE = warmstate.THRESHOLD_LIMIT // 2  # 50%
    #
    for i in range(0, 20005):
        get_jitcell(True, i)
        assert len(warmstate._jitcell_dict) == (i % 19999) + 2
    #
    assert cell2 in warmstate._jitcell_dict.values()
    assert cell2.counter == int(BASE * 0.92)  # decayed once
    #
    # Same test, with jitcells that are compiled and freed by the memmgr
    warmstate = WarmEnterState(None, FakeJitDriverSD())
    get_jitcell = warmstate._make_jitcell_getter_default()
    get_jitcell(True, -1)
    #
    for i in range(1, 20005):
        cell = get_jitcell(True, i)
        cell.counter = -1
        cell.wref_procedure_token = None  # or a dead weakref, equivalently
        assert len(warmstate._jitcell_dict) == (i % 20000) + 1
    #
    # Same test, with counter == -2 (rare case, kept alive)
    warmstate = WarmEnterState(None, FakeJitDriverSD())
    get_jitcell = warmstate._make_jitcell_getter_default()
    cell = get_jitcell(True, -1)
    cell.counter = -2
    #
    for i in range(1, 20005):
        cell = get_jitcell(True, i)
        cell.counter = -2
        assert len(warmstate._jitcell_dict) == i + 1
开发者ID:junion,项目名称:butlerbot-unstable,代码行数:51,代码来源:test_warmstate.py

示例2: test_make_jitcell_getter_default

# 需要导入模块: from pypy.jit.metainterp.warmstate import WarmEnterState [as 别名]
# 或者: from pypy.jit.metainterp.warmstate.WarmEnterState import _make_jitcell_getter_default [as 别名]
def test_make_jitcell_getter_default():
    class FakeWarmRunnerDesc:
        green_args_spec = [lltype.Signed, lltype.Float]
    class FakeJitCell(BaseJitCell):
        pass
    state = WarmEnterState(FakeWarmRunnerDesc())
    get_jitcell = state._make_jitcell_getter_default(FakeJitCell)
    cell1 = get_jitcell(42, 42.5)
    assert isinstance(cell1, FakeJitCell)
    cell2 = get_jitcell(42, 42.5)
    assert cell1 is cell2
    cell3 = get_jitcell(41, 42.5)
    cell4 = get_jitcell(42, 0.25)
    assert cell1 is not cell3 is not cell4 is not cell1
开发者ID:alkorzt,项目名称:pypy,代码行数:16,代码来源:test_warmstate.py

示例3: test_make_jitcell_getter_default

# 需要导入模块: from pypy.jit.metainterp.warmstate import WarmEnterState [as 别名]
# 或者: from pypy.jit.metainterp.warmstate.WarmEnterState import _make_jitcell_getter_default [as 别名]
def test_make_jitcell_getter_default():
    class FakeJitDriverSD:
        _green_args_spec = [lltype.Signed, lltype.Float]
    state = WarmEnterState(None, FakeJitDriverSD())
    get_jitcell = state._make_jitcell_getter_default()
    cell1 = get_jitcell(True, 42, 42.5)
    assert isinstance(cell1, JitCell)
    cell2 = get_jitcell(True, 42, 42.5)
    assert cell1 is cell2
    cell3 = get_jitcell(True, 41, 42.5)
    assert get_jitcell(False, 42, 0.25) is None
    cell4 = get_jitcell(True, 42, 0.25)
    assert get_jitcell(False, 42, 0.25) is cell4
    assert cell1 is not cell3 is not cell4 is not cell1
开发者ID:gorakhargosh,项目名称:pypy,代码行数:16,代码来源:test_warmstate.py


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