Exemplo n.º 1
0
def test_really_run():
    """ This test checks whether output of jitprof did not change.
    It'll explode when someone touches jitprof.py
    """
    mydriver = JitDriver(reds = ['i', 'n'], greens = [])
    def f(n):
        i = 0
        while i < n:
            mydriver.can_enter_jit(i=i, n=n)
            mydriver.jit_merge_point(i=i, n=n)
            i += 1

    cap = py.io.StdCaptureFD()
    try:
        ll_meta_interp(f, [10], CPUClass=runner.LLtypeCPU, type_system='lltype',
                       ProfilerClass=Profiler)
    finally:
        out, err = cap.reset()

    log = parse_log(err.splitlines(True))
    err_sections = list(extract_category(log, 'jit-summary'))
    [err1] = err_sections    # there should be exactly one jit-summary
    assert err1.count("\n") == JITPROF_LINES
    info = parse_prof(err1)
    # assert did not crash
    # asserts below are a bit delicate, possibly they might be deleted
    assert info.tracing_no == 1
    assert info.backend_no == 1
    assert info.ops.total == 2
    assert info.recorded_ops.total == 2
    assert info.recorded_ops.calls == 0
    assert info.guards == 1
    assert info.opt_ops == 13
    assert info.opt_guards == 2
    assert info.forcings == 0
Exemplo n.º 2
0
def test_parse():
    info = parse_prof(DATA)
    assert info.tracing_no == 1
    assert info.tracing_time == 0.006992
    assert info.asm_no == 1
    assert info.blackhole_no == 1
    assert info.backend_no == 1
    assert info.backend_time == 0.000525
    assert info.ops.total == 2
    assert info.ops.calls == 1
    assert info.ops.pure_calls == 1
    assert info.recorded_ops.total == 6
    assert info.recorded_ops.calls == 3
    assert info.recorded_ops.pure_calls == 2
    assert info.guards == 1
    assert info.blackholed_ops.total == 5
    assert info.blackholed_ops.pure_calls == 3
    assert info.opt_ops == 6
    assert info.opt_guards == 1
    assert info.forcings == 1
    assert info.abort.trace_too_long == 10
    assert info.abort.compiling == 11
    assert info.abort.vable_escape == 12
    assert info.nvirtuals == 13
    assert info.nvholes == 14
    assert info.nvreused == 15
Exemplo n.º 3
0
def test_parse():
    info = parse_prof(DATA)
    assert info.tracing_no == 1
    assert info.tracing_time == 0.006992
    assert info.asm_no == 1
    assert info.blackhole_no == 1
    assert info.backend_no == 1
    assert info.backend_time == 0.000525
    assert info.ops.total == 2
    assert info.ops.calls == 1
    assert info.ops.pure_calls == 1
    assert info.recorded_ops.total == 6
    assert info.recorded_ops.calls == 3
    assert info.recorded_ops.pure_calls == 2
    assert info.guards == 1
    assert info.blackholed_ops.total == 5
    assert info.blackholed_ops.pure_calls == 3
    assert info.opt_ops == 6
    assert info.opt_guards == 1
    assert info.forcings == 1
    assert info.abort.trace_too_long == 10
    assert info.abort.compiling == 11
    assert info.abort.vable_escape == 12
    assert info.nvirtuals == 13
    assert info.nvholes == 14
    assert info.nvreused == 15
Exemplo n.º 4
0
 def run(self, func_or_src, args=[], import_site=False, **jitopts):
     jitopts.setdefault('threshold', 200)
     src = py.code.Source(func_or_src)
     if isinstance(func_or_src, types.FunctionType):
         funcname = func_or_src.func_name
     else:
         funcname = 'main'
     # write the snippet
     arglist = ', '.join(map(repr, args))
     with self.filepath.open("w") as f:
         # we don't want to see the small bridges created
         # by the checkinterval reaching the limit
         f.write("import sys\n")
         f.write("sys.setcheckinterval(10000000)\n")
         f.write(str(src) + "\n")
         f.write("print %s(%s)\n" % (funcname, arglist))
     #
     # run a child pypy-c with logging enabled
     logfile = self.filepath.new(ext='.log')
     #
     cmdline = [sys.executable]
     if not import_site:
         cmdline.append('-S')
     if jitopts:
         jitcmdline = ['%s=%s' % (key, value)
                       for key, value in jitopts.items()]
         cmdline += ['--jit', ','.join(jitcmdline)]
     cmdline.append(str(self.filepath))
     #
     env = os.environ.copy()
     env['PYPYLOG'] = self.log_string + ':' + str(logfile)
     pipe = subprocess.Popen(cmdline,
                             env=env,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
     stdout, stderr = pipe.communicate()
     if getattr(pipe, 'returncode', 0) < 0:
         raise IOError("subprocess was killed by signal %d" % (
             pipe.returncode,))
     if stderr.startswith('SKIP:'):
         py.test.skip(stderr)
     if stderr.startswith('debug_alloc.h:'):   # lldebug builds
         stderr = ''
     assert not stderr
     #
     # parse the JIT log
     rawlog = logparser.parse_log_file(str(logfile))
     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
Exemplo n.º 5
0
def test_really_run():
    """ This test checks whether output of jitprof did not change.
    It'll explode when someone touches jitprof.py
    """
    mydriver = JitDriver(reds=['i', 'n'], greens=[])

    def f(n):
        i = 0
        while i < n:
            mydriver.can_enter_jit(i=i, n=n)
            mydriver.jit_merge_point(i=i, n=n)
            i += 1

    cap = py.io.StdCaptureFD()
    try:
        ll_meta_interp(f, [10],
                       CPUClass=runner.LLtypeCPU,
                       type_system='lltype',
                       ProfilerClass=Profiler,
                       debug_level=DEBUG_PROFILE)
    finally:
        out, err = cap.reset()
    err = "\n".join(err.splitlines()[-JITPROF_LINES:])
    print err
    assert err.count("\n") == JITPROF_LINES - 1
    info = parse_prof(err)
    # assert did not crash
    # asserts below are a bit delicate, possibly they might be deleted
    assert info.tracing_no == 1
    assert info.asm_no == 1
    assert info.blackhole_no == 1
    assert info.backend_no == 1
    assert info.ops.total == 2
    assert info.ops.calls == 0
    assert info.ops.pure_calls == 0
    assert info.recorded_ops.total == 2
    assert info.recorded_ops.calls == 0
    assert info.recorded_ops.pure_calls == 0
    assert info.guards == 1
    assert info.blackholed_ops.total == 0
    assert info.blackholed_ops.pure_calls == 0
    assert info.opt_ops == 6
    assert info.opt_guards == 1
    assert info.forcings == 0
    assert info.trace_too_long == 0
    assert info.bridge_abort == 0
Exemplo n.º 6
0
def test_really_run():
    """ This test checks whether output of jitprof did not change.
    It'll explode when someone touches jitprof.py
    """
    mydriver = JitDriver(reds = ['i', 'n'], greens = [])
    def f(n):
        i = 0
        while i < n:
            mydriver.can_enter_jit(i=i, n=n)
            mydriver.jit_merge_point(i=i, n=n)
            i += 1

    cap = py.io.StdCaptureFD()
    try:
        ll_meta_interp(f, [10], CPUClass=runner.LLtypeCPU, type_system='lltype',
                       ProfilerClass=Profiler, debug_level=DEBUG_PROFILE)
    finally:
        out, err = cap.reset()
    err = "\n".join(err.splitlines()[-JITPROF_LINES:])
    print err
    assert err.count("\n") == JITPROF_LINES - 1
    info = parse_prof(err)
    # assert did not crash
    # asserts below are a bit delicate, possibly they might be deleted
    assert info.tracing_no == 1
    assert info.asm_no == 1
    assert info.blackhole_no == 1
    assert info.backend_no == 1
    assert info.ops.total == 2
    assert info.ops.calls == 0
    assert info.ops.pure_calls == 0
    assert info.recorded_ops.total == 2
    assert info.recorded_ops.calls == 0
    assert info.recorded_ops.pure_calls == 0
    assert info.guards == 1
    assert info.blackholed_ops.total == 0
    assert info.blackholed_ops.pure_calls == 0
    assert info.opt_ops == 6
    assert info.opt_guards == 1
    assert info.forcings == 0
    assert info.trace_too_long == 0
    assert info.bridge_abort == 0    
Exemplo n.º 7
0
def test_really_run():
    """ This test checks whether output of jitprof did not change.
    It'll explode when someone touches jitprof.py
    """
    mydriver = JitDriver(reds=['i', 'n'], greens=[])

    def f(n):
        i = 0
        while i < n:
            mydriver.can_enter_jit(i=i, n=n)
            mydriver.jit_merge_point(i=i, n=n)
            i += 1

    cap = py.io.StdCaptureFD()
    try:
        ll_meta_interp(f, [10],
                       CPUClass=runner.LLtypeCPU,
                       type_system='lltype',
                       ProfilerClass=Profiler)
    finally:
        out, err = cap.reset()

    log = parse_log(err.splitlines(True))
    err_sections = list(extract_category(log, 'jit-summary'))
    [err1] = err_sections  # there should be exactly one jit-summary
    assert err1.count("\n") == JITPROF_LINES
    info = parse_prof(err1)
    # assert did not crash
    # asserts below are a bit delicate, possibly they might be deleted
    assert info.tracing_no == 1
    assert info.backend_no == 1
    assert info.ops.total == 2
    assert info.recorded_ops.total == 2
    assert info.recorded_ops.calls == 0
    assert info.guards == 1
    assert info.opt_ops == 13
    assert info.opt_guards == 2
    assert info.forcings == 0
Exemplo n.º 8
0
def test_parse():
    info = parse_prof(DATA)
    assert info.tracing_no == 1
    assert info.tracing_time == 0.006992
    assert info.asm_no == 1
    assert info.asm_time == 0.016957
    assert info.blackhole_no == 1
    assert info.blackhole_time == 0.000233
    assert info.backend_no == 1
    assert info.backend_time == 0.000525
    assert info.ops.total == 2
    assert info.ops.calls == 1
    assert info.ops.pure_calls == 1
    assert info.recorded_ops.total == 6
    assert info.recorded_ops.calls == 3
    assert info.recorded_ops.pure_calls == 2
    assert info.guards == 1
    assert info.blackholed_ops.total == 5
    assert info.blackholed_ops.pure_calls == 3
    assert info.opt_ops == 6
    assert info.opt_guards == 1
    assert info.forcings == 1
    assert info.trace_too_long == 2
    assert info.bridge_abort == 3  
Exemplo n.º 9
0
def test_parse():
    info = parse_prof(DATA)
    assert info.tracing_no == 1
    assert info.tracing_time == 0.006992
    assert info.asm_no == 1
    assert info.asm_time == 0.016957
    assert info.blackhole_no == 1
    assert info.blackhole_time == 0.000233
    assert info.backend_no == 1
    assert info.backend_time == 0.000525
    assert info.ops.total == 2
    assert info.ops.calls == 1
    assert info.ops.pure_calls == 1
    assert info.recorded_ops.total == 6
    assert info.recorded_ops.calls == 3
    assert info.recorded_ops.pure_calls == 2
    assert info.guards == 1
    assert info.blackholed_ops.total == 5
    assert info.blackholed_ops.pure_calls == 3
    assert info.opt_ops == 6
    assert info.opt_guards == 1
    assert info.forcings == 1
    assert info.trace_too_long == 2
    assert info.bridge_abort == 3