Author: Antonio Cuni <anto.c...@gmail.com> Branch: Changeset: r44732:eaab7d9aae6b Date: 2011-06-06 13:37 +0200 http://bitbucket.org/pypy/pypy/changeset/eaab7d9aae6b/
Log: port this test to test_pypy_c_new diff --git a/pypy/module/pypyjit/test/test_pypy_c.py b/pypy/module/pypyjit/test/test_pypy_c.py --- a/pypy/module/pypyjit/test/test_pypy_c.py +++ b/pypy/module/pypyjit/test/test_pypy_c.py @@ -347,20 +347,6 @@ ([a2, b2], 2000 * res2), ([a3, b3], 2000 * res3)) - def test_dont_trace_every_iteration(self): - self.run_source(''' - def main(a, b): - i = sa = 0 - while i < 200: - if a > 0: pass - if 1 < b < 2: pass - sa += a % b - i += 1 - return sa - ''', 22, ([10, 20], 200 * (10 % 20)), - ([-10, -20], 200 * (-10 % -20)), - count_debug_merge_point=False) - assert self.jit_summary.tracing_no == 2 def test_id_compare_optimization(self): # XXX: lower the instruction count, 35 is the old value. self.run_source(""" diff --git a/pypy/module/pypyjit/test_pypy_c/test_model.py b/pypy/module/pypyjit/test_pypy_c/test_model.py --- a/pypy/module/pypyjit/test_pypy_c/test_model.py +++ b/pypy/module/pypyjit/test_pypy_c/test_model.py @@ -5,6 +5,7 @@ from lib_pypy import disassembler from pypy.tool.udir import udir from pypy.tool import logparser +from pypy.jit.tool.jitoutput import parse_prof from pypy.module.pypyjit.test_pypy_c.model import Log, find_ids_range, find_ids, \ LoopWithIds, OpMatcher @@ -63,6 +64,13 @@ rawtraces = logparser.extract_category(rawlog, 'jit-log-opt-') log = Log(rawtraces) log.result = eval(stdout) + # + summaries = logparser.extract_category(rawlog, 'jit-summary') + if len(summaries) > 0: + log.jit_summary = parse_prof(summaries[-1]) + else: + log.jit_summary = None + # return log def run_and_check(self, src, args=[], **jitopts): diff --git a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py --- a/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py +++ b/pypy/module/pypyjit/test_pypy_c/test_pypy_c_new.py @@ -1731,3 +1731,33 @@ loop.match_by_id("contains", """ i1 = int_add(i0, 1) """) + + def test_dont_trace_every_iteration(self): + def main(a, b): + i = sa = 0 + while i < 300: + if a > 0: + pass + if 1 < b < 2: + pass + sa += a % b + i += 1 + return sa + # + log = self.run(main, [10, 20], threshold=200) + assert log.result == 300 * (10 % 20) + assert log.jit_summary.tracing_no == 1 + loop, = log.loops_by_filename(self.filepath) + assert loop.match(""" + i11 = int_lt(i7, 300) + guard_true(i11, descr=<Guard3>) + i12 = int_add_ovf(i8, i9) + guard_no_overflow(descr=<Guard4>) + i14 = int_add(i7, 1) + --TICK-- + jump(..., descr=...) + """) + # + log = self.run(main, [-10, -20], threshold=200) + assert log.result == 300 * (-10 % -20) + assert log.jit_summary.tracing_no == 1 _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit