コード例 #1
0
def test_import_log_2():
    if not autodetect().startswith("x86"):
        py.test.skip("x86 only test")
    _, loops = import_log(str(py.path.local(__file__).join("..", "logtest2.log")))
    for loop in loops:
        loop.force_asm()
    assert "cmp" in loops[1].operations[2].asm
コード例 #2
0
ファイル: logparser2json.py プロジェクト: Darriall/pypy
def main(progname, logfilename, outfilename):
    storage = LoopStorage(extrapath=os.path.dirname(progname))
    log, loops = import_log(logfilename)
    parse_log_counts(extract_category(log, 'jit-backend-count'), loops)
    storage.loops = [loop for loop in loops
                     if not loop.descr.startswith('bridge')]
    storage.loop_dict = create_loop_dict(loops)
    json.dump([loop.force_asm().as_json() for loop in storage.loops],
              open(outfilename, "w"), indent=4)
コード例 #3
0
def test_import_log_2():
    if not autodetect().startswith('x86'):
        py.test.skip('x86 only test')
    _, loops = import_log(
        str(py.path.local(__file__).join('..', 'logtest2.log')))
    try:
        for loop in loops:
            loop.force_asm()
    except ObjdumpNotFound:
        py.test.skip('no objdump found on path')
    assert 'cmp' in loops[1].operations[2].asm
コード例 #4
0
ファイル: test_parser.py プロジェクト: Darriall/pypy
def test_import_log_2():
    if not autodetect().startswith('x86'):
        py.test.skip('x86 only test')
    _, loops = import_log(str(py.path.local(__file__).join('..',
                                                           'logtest2.log')))
    try:
        for loop in loops:
            loop.force_asm()
    except ObjdumpNotFound:
        py.test.skip('no objdump found on path')
    assert 'cmp' in loops[1].operations[2].asm
コード例 #5
0
def main(progname, logfilename, outfilename):
    storage = LoopStorage(extrapath=os.path.dirname(progname))
    log, loops = import_log(logfilename)
    parse_log_counts(extract_category(log, 'jit-backend-count'), loops)
    storage.loops = [
        loop for loop in loops if not loop.descr.startswith('bridge')
    ]
    storage.loop_dict = create_loop_dict(loops)
    json.dump([loop.force_asm().as_json() for loop in storage.loops],
              open(outfilename, "w"),
              indent=4)
コード例 #6
0
def test_import_log():
    if sys.platform == 'win32' or not autodetect().startswith('x86'):
        py.test.skip('x86 only test')
    _, loops = import_log(str(py.path.local(__file__).join('..',
                                                           'logtest.log')))
    try:
        for loop in loops:
            loop.force_asm()
    except ObjdumpNotFound:
        py.test.skip('no objdump found on path')
    assert 'jge' in loops[0].operations[3].asm
コード例 #7
0
ファイル: test_jitlogparser.py プロジェクト: tools-env/mesapy
    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

        #
        N = 10000
        _log = self.run(fn_with_bridges, [N])
        log, loops = import_log(_log.logfile)
        parse_log_counts(extract_category(log, 'jit-backend-count'), loops)

        is_prime_loops = []
        fn_with_bridges_loops = []
        bridges = {}

        lib_re = re.compile("file '.*lib-python.*'")
        for loop in loops:
            if hasattr(loop, 'force_asm'):
                try:
                    loop.force_asm()
                except ObjdumpNotFound:
                    py.test.skip("ObjDump was not found, skipping")
            if lib_re.search(loop.comment) or \
                    lib_re.search(loop.operations[0].repr()):
                # do not care for _optimize_charset or _mk_bitmap
                continue
            assert loop.count > 0
            if ' is_prime, ' in loop.comment:
                is_prime_loops.append(loop)
            elif ' fn_with_bridges, ' in loop.comment:
                fn_with_bridges_loops.append(loop)
            else:
                assert ' bridge ' in loop.comment
                key = mangle_descr(loop.descr)
                assert key not in bridges
                bridges[key] = loop

        by_count = lambda l: -l.count
        is_prime_loops.sort(key=by_count)
        fn_with_bridges_loops.sort(key=by_count)

        # check that we can find bridges corresponding to " % 3" and " % 5"
        mod_bridges = []
        for op in fn_with_bridges_loops[0].operations:
            if op.descr is not None:
                bridge = bridges.get(mangle_descr(op.descr))
                if bridge is not None:
                    mod_bridges.append(bridge)
        assert len(mod_bridges) in (1, 2, 3)

        # check that counts are reasonable (precise # may change in the future)
        assert N - 2000 < sum(l.count
                              for l in fn_with_bridges_loops) < N + 1500
コード例 #8
0
ファイル: test_jitlogparser.py プロジェクト: Darriall/pypy
    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
        #
        N = 10000
        _log = self.run(fn_with_bridges, [N])
        log, loops = import_log(_log.logfile)
        parse_log_counts(extract_category(log, 'jit-backend-count'), loops)

        is_prime_loops = []
        fn_with_bridges_loops = []
        bridges = {}

        lib_re = re.compile("file '.*lib-python.*'")
        for loop in loops:
            if hasattr(loop, 'force_asm'):
                try:
                    loop.force_asm()
                except ObjdumpNotFound:
                    py.test.skip("ObjDump was not found, skipping")
            if lib_re.search(loop.comment) or \
                    lib_re.search(loop.operations[0].repr()):
                # do not care for _optimize_charset or _mk_bitmap
                continue
            assert loop.count > 0
            if ' is_prime, ' in loop.comment:
                is_prime_loops.append(loop)
            elif ' fn_with_bridges, ' in loop.comment:
                fn_with_bridges_loops.append(loop)
            else:
                assert ' bridge ' in loop.comment
                key = mangle_descr(loop.descr)
                assert key not in bridges
                bridges[key] = loop

        by_count = lambda l: -l.count
        is_prime_loops.sort(key=by_count)
        fn_with_bridges_loops.sort(key=by_count)

        # check that we can find bridges corresponding to " % 3" and " % 5"
        mod_bridges = []
        for op in fn_with_bridges_loops[0].operations:
            if op.descr is not None:
                bridge = bridges.get(mangle_descr(op.descr))
                if bridge is not None:
                    mod_bridges.append(bridge)
        assert len(mod_bridges) in (1, 2, 3)

        # check that counts are reasonable (precise # may change in the future)
        assert N - 2000 < sum(l.count for l in fn_with_bridges_loops) < N + 1000