Debian Codegraph @

rpython/jit/tl/targettlc.py

raw symbols SCIP
1 from __future__ import print_function
2
3 import time
4 import py
5 py.path.local(__file__)
6 from rpython.jit.tl.tlc import interp, interp_nonjit, ConstantPool
7 from rpython.jit.backend.hlinfo import highleveljitinfo
8
9
10 def entry_point(args):
11 """Main entry point of the stand-alone executable:
12 takes a list of strings and returns the exit code.
13 """
14 # store args[0] in a place where the JIT log can find it (used by
15 # viewcode.py to know the executable whose symbols it should display)
16 exe = args[0]
17 args = args[1:]
18 highleveljitinfo.sys_executable = exe
19 if len(args) < 2:
20 print("Usage: %s [--onlyjit] filename x" % (exe,))
21 return 2
22
23 onlyjit = False
24 if args[0] == '--onlyjit':
25 onlyjit = True
26 args = args[1:]
27
28 filename = args[0]
29 x = int(args[1])
30 bytecode, pool = load_bytecode(filename)
31
32 if not onlyjit:
33 start = time.clock()
34 res = interp_nonjit(bytecode, inputarg=x, pool=pool)
35 stop = time.clock()
36 print('Non jitted: %d (%f seconds)' % (res, stop-start))
37
38 start = time.clock()
39 res = interp(bytecode, inputarg=x, pool=pool)
40 stop = time.clock()
41 print('Warmup jitted: %d (%f seconds)' % (res, stop-start))
42
43 start = time.clock()
44 res = interp(bytecode, inputarg=x, pool=pool)
45 stop = time.clock()
46 print('Warmed jitted: %d (%f seconds)' % (res, stop-start))
47
48 return 0
49
50
51 def load_bytecode(filename):
52 from rpython.rlib.streamio import open_file_as_stream
53 from rpython.jit.tl.tlopcode import decode_program
54 f = open_file_as_stream(filename)
55 return decode_program(f.readall())
56
57 def target(driver, args):
58 return entry_point
59
60 # ____________________________________________________________
61
62 if __name__ == '__main__':
63 import sys
64 sys.exit(entry_point(sys.argv))