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.LLGraphCPU, 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 == 2 assert info.opt_ops == 13 assert info.opt_guards == 2 assert info.forcings == 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.LLGraphCPU, 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 == 2 assert info.opt_ops == 11 assert info.opt_guards == 2 assert info.forcings == 0
def main(arg, plot=False): log = parse_log(open(arg).readlines()) all = [] for entry in log: if entry[0].startswith('gc-collect'): start = entry[1] end = entry[2] all.append(float(end - start) / 1000000) format_output(all, plot=plot)