This repository was archived by the owner on Jan 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtargetstandalone.py
63 lines (53 loc) · 1.49 KB
/
targetstandalone.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import sys
import os
import time
# __________ Entry point __________
from expression import NumericExpression, VariableExpression
from petri_net import PetriNet
from propositions import LessProposition, EUProposition, EqualsProposition
from transition import Transition
from state import State
from parse import parse_net, parse_props
def entry_point(argv):
file = argv[1]
net, state = parse_net(read_file(file))
props = parse_props(argv[2])
for prop in props:
print prop.label()
g_start = time.time()
for p in props:
print p.label(),"= ",
start = time.time()
res = state.evaluate(p)
end = time.time()
if res:
print "True",
else:
print "False",
print "(%f)" % (end -start,)
g_end = time.time()
print "Total runtime %f" % (g_end - g_start, )
print "Calculated %d states" % len(net._states_cache)
return 0
def read_file(filename):
fd = os.open(filename, os.O_RDONLY, 0777)
content = []
while 1:
s = os.read(fd, 4096)
if not s:
break
content.append(s)
file_content = "".join(content)
os.close(fd)
return file_content
# _____ Define and setup target ___
def target(driver, args):
driver.exe_name = 'pytri-%(backend)s'
return entry_point, None
def portal(driver):
pass
def jitpolicy(self):
from pypy.jit.metainterp.policy import JitPolicy
return JitPolicy()
if __name__ == '__main__':
entry_point(sys.argv)