Debian Codegraph @

rpython/jit/tool/test/test_jitoutput.py

raw symbols SCIP
1
2 import py
3 from rpython.jit.metainterp.warmspot import ll_meta_interp
4 from rpython.rlib.jit import JitDriver
5 from rpython.jit.backend.llgraph import runner
6 from rpython.jit.metainterp.jitprof import Profiler, JITPROF_LINES
7 from rpython.jit.tool.jitoutput import parse_prof
8 from rpython.tool.logparser import parse_log, extract_category
9
10 def test_really_run():
11 """ This test checks whether output of jitprof did not change.
12 It'll explode when someone touches jitprof.py
13 """
14 mydriver = JitDriver(reds = ['i', 'n'], greens = [])
15 def f(n):
16 i = 0
17 while i < n:
18 mydriver.can_enter_jit(i=i, n=n)
19 mydriver.jit_merge_point(i=i, n=n)
20 i += 1
21
22 cap = py.io.StdCaptureFD()
23 try:
24 ll_meta_interp(f, [10], CPUClass=runner.LLGraphCPU,
25 ProfilerClass=Profiler)
26 finally:
27 out, err = cap.reset()
28
29 log = parse_log(err.splitlines(True))
30 err_sections = list(extract_category(log, 'jit-summary'))
31 [err1] = err_sections # there should be exactly one jit-summary
32 assert err1.count("\n") == JITPROF_LINES
33 info = parse_prof(err1)
34 # assert did not crash
35 # asserts below are a bit delicate, possibly they might be deleted
36 assert info.tracing_no == 1
37 assert info.backend_no == 1
38 assert info.ops.total == 2
39 assert info.recorded_ops.total == 2
40 assert info.recorded_ops.calls == 0
41 assert info.guards == 2
42 assert info.opt_ops == 11
43 assert info.opt_guards == 2
44 assert info.forcings == 0
45
46 DATA = '''Tracing: 1 0.006992
47 Backend: 1 0.000525
48 TOTAL: 0.025532
49 ops: 2
50 heapcached ops: 111
51 recorded ops: 6
52 calls: 3
53 guards: 1
54 opt ops: 6
55 opt guards: 1
56 opt guards shared: 1
57 forcings: 1
58 abort: trace too long: 10
59 abort: compiling: 11
60 abort: vable escape: 12
61 abort: bad loop: 135
62 abort: force quasi-immut: 3
63 abort: segmenting trace: 0
64 virtualizables forced: 1123
65 nvirtuals: 13
66 nvholes: 14
67 nvreused: 15
68 vecopt tried: 12
69 vecopt success: 4
70 Total # of loops: 100
71 Total # of bridges: 300
72 Freed # of loops: 99
73 Freed # of bridges: 299
74 '''
75
76 def test_parse():
77 info = parse_prof(DATA)
78 assert info.tracing_no == 1
79 assert info.tracing_time == 0.006992
80 assert info.backend_no == 1
81 assert info.backend_time == 0.000525
82 assert info.ops.total == 2
83 assert info.heapcached_ops == 111
84 assert info.recorded_ops.total == 6
85 assert info.recorded_ops.calls == 3
86 assert info.guards == 1
87 assert info.opt_ops == 6
88 assert info.opt_guards == 1
89 assert info.forcings == 1
90 assert info.abort.trace_too_long == 10
91 assert info.abort.compiling == 11
92 assert info.abort.vable_escape == 12
93 assert info.abort.bad_loop == 135
94 assert info.abort.force_quasiimmut == 3
95 assert info.virtualizables_forced == 1123
96 assert info.nvirtuals == 13
97 assert info.nvholes == 14
98 assert info.nvreused == 15
99 assert info.vecopt_tried == 12
100 assert info.vecopt_success == 4