-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrewritertester.py
42 lines (32 loc) · 919 Bytes
/
rewritertester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from instructionexecutor import InstructionExecutor
from rewriter import Rewriter
from tracereader import EffectReader, TraceReader
from ceptions import TimeoutException
import signal, sys
def handler(signum, frame):
raise TimeoutException("timeout")
class RewriterTester:
def __init__(self, line):
reader = EffectReader(line)
# reader = TraceReader(line)
reader.parse_trace()
self.code_size = len(reader.code)
signal.signal(signal.SIGALRM, handler)
signal.alarm(15)
# print(reader.signature)
rewriter = Rewriter(reader.code)
InstructionExecutor(reader, rewriter)
signal.alarm(0)
def get_code_size(self):
return self.code_size
if __name__ == "__main__":
line = open(sys.argv[1]).readline()
RewriterTester(line)
# for count, line in enumerate(open(sys.argv[1])):
# if count == 100:
# break
# try:
# OptimizerTester(line)
# except Exception as e:
# print(count, e)
#