Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r71131:c7196a03a054 Date: 2014-05-01 14:05 +0200 http://bitbucket.org/pypy/pypy/changeset/c7196a03a054/
Log: Add a pypy-c test for issue #1328 diff --git a/pypy/module/pypyjit/test_pypy_c/test_cprofile.py b/pypy/module/pypyjit/test_pypy_c/test_cprofile.py new file mode 100644 --- /dev/null +++ b/pypy/module/pypyjit/test_pypy_c/test_cprofile.py @@ -0,0 +1,31 @@ +import py +from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC + +class TestCProfile(BaseTestPyPyC): + + def test_cprofile_builtin(self): + def main(n): + import _lsprof + prof = _lsprof.Profiler() + i = 0 + lst = [] + prof.enable() + while i < n: + lst.append(i) # ID: append + lst.pop() # ID: pop + i += 1 + prof.disable() + return [(entry.code, entry.callcount) for entry in prof.getstats()] + # + log = self.run(main, [500]) + assert sorted(log.result) == [ + ("{method 'append' of 'list' objects}", 500), + ("{method 'disable' of '_lsprof.Profiler' objects}", 1), + ("{method 'pop' of 'list' objects}", 500), + ] + for method in ['append', 'pop']: + loop, = log.loops_by_id(method) + print loop.ops_by_id(method) + assert 'call(' not in repr(loop.ops_by_id(method)) + assert 'call_may_force(' not in repr(loop.ops_by_id(method)) + assert 'call_cond(' in repr(loop.ops_by_id(method)) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit