Commits

Konstantin Lopuhin committed 84b2a0a

move test to tests_pypy_c

Comments (0)

Files changed (3)

pypy/module/pypyjit/test_pypy_c/test_jitlogparser.py

+from rpython.tool.logparser import extract_category
+
+from pypy.tool.jitlogparser.parser import import_log, parse_log_counts
+from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
+
+
+class TestLogParser(BaseTestPyPyC):
+
+    def test(self):
+        def fn_with_bridges(N):
+            def is_prime(x):
+                for y in xrange(2, x):
+                    if x % y == 0:
+                        return False
+                return True
+            result = 0
+            for x in xrange(N):
+                if x % 3 == 0:
+                    result += 5
+                elif x % 5 == 0:
+                    result += 3
+                elif is_prime(x):
+                    result += x
+                elif x == 99:
+                    result *= 2
+            return result
+        #
+        log = self.run(fn_with_bridges, [10000])
+        print log
+        import pdb; pdb.set_trace()
+        # TODO
+        log, loops = import_log(log_filename)
+        parse_log_counts(extract_category(log, 'jit-backend-count'), loops)
+        lib_re = re.compile("file '.*lib-python.*'")
+        for loop in loops:
+            loop.force_asm()
+            if lib_re.search(loop.comment) or \
+                    lib_re.search(loop.operations[0].repr()):
+                # do not care for _optimize_charset or _mk_bitmap
+                continue
+            else:
+                import pdb; pdb.set_trace()
+
+

pypy/tool/jitlogparser/test/test_parser.py

-import re
-import os.path
-import tempfile
-import subprocess
-
 from pypy.tool.jitlogparser.parser import (SimpleParser, TraceForOpcode,
                                            Function, adjust_bridges,
                                            import_log, split_trace, Op,
 from pypy.tool.jitlogparser.storage import LoopStorage
 import py, sys
 from rpython.jit.backend.detect_cpu import autodetect_main_model
-from rpython.tool.logparser import extract_category
 
 
 def parse(input, **kwds):
     """)
     f = Function.from_operations(loop.operations, LoopStorage())
     assert len(f.chunks) == 2
-    
-def test_import_log_on_pypy():
-    ''' Test import_log and parse_log_counts on a log from actual pypy run
-    '''
-    log_filename = tempfile.mktemp()
-    pypy = '/Users/kostia/programming/pypy/pypy-c' # FIXME
-    subprocess.check_call([pypy, 
-        os.path.join(os.path.dirname(__file__), 'y.py')],
-        env={'PYPYLOG': 'jit-log-opt,jit-backend:%s' % log_filename})
-    log, loops = import_log(log_filename)
-    parse_log_counts(extract_category(log, 'jit-backend-count'), loops)
-    lib_re = re.compile("file '.*lib-python.*'")
-    for loop in loops:
-        loop.force_asm()
-        if lib_re.search(loop.comment) or \
-                lib_re.search(loop.operations[0].repr()):
-            # do not care for _optimize_charset or _mk_bitmap
-            continue
-        else:
-            import pdb; pdb.set_trace()
-

pypy/tool/jitlogparser/test/y.py

-
-def fn_with_bridges(N):
-    result = 0
-    for x in xrange(N):
-        if x % 3 == 0:
-            result += 5
-        elif x % 5 == 0:
-            result += 3
-        elif is_prime(x):
-            result += x
-        elif x == 99:
-            result *= 2
-    return result
-
-
-def is_prime(x):
-    for y in xrange(2, x):
-        if x % y == 0:
-            return False
-    return True
-
-
-fn_with_bridges(10000)
-