-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpathTimeComparison.py
30 lines (25 loc) · 1.35 KB
/
pathTimeComparison.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
#analyses a path group's deadended paths
class TimeAnalysis(object):
#__init__():
# return a list containging, for each path, a list of achievable execution times
def possibleTimes(self, pg):
timingList = []
for i,p in enumerate(pg.deadended):
timingList.append(pathTime(p))
return timingList
# return a list with possible execution times for this path
# maxLength is the maximum length of the returned list that will be computed
# TODO: big bug: this currently evaluates constraints using the latest state, but constraints on timing at a certain point should of course be evaluated with the constraints of THAT state. either concretize immediately (possibly branch on multiple concretizations), copy constraints uniquely, or remember old states in timing plugin
def pathTime(self, p, maxLength=10):
return p.state.se.eval(p.state.time.totalExecutionTime, maxLength)
# counts unique timings in a tuple, or list of tuples.
# we assume we don't receive an empty list.
def countUniqueTimings(self, times):
foundTimes = set([])
if isinstance(times[0],tuple):
# it's a list of tuples
for t in times:
foundTimes = foundTimes.union(set(t))
return len(foundTimes)
else:
return len(set(times))