summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMac Mollison <mollison@cs.unc.edu>2009-02-01 21:55:18 -0500
committerMac Mollison <mollison@cs.unc.edu>2009-02-01 21:55:18 -0500
commit0c95b7332d08cbf45f25fae04bb5595489ba6dec (patch)
tree7b2f1665c317033aed6114de458a968af81cc1c6
parent00301e7f56ae8baad48155c22ff294666576fedf (diff)
Added more complicated filter mechanism, added run.py which demonstrates the current abilities of STA, and added list.py, which is used by run.py. Updated DEV_NOTES.
-rw-r--r--DEV_NOTES10
-rw-r--r--list.py14
-rwxr-xr-xrun.py12
-rwxr-xr-xsta.py30
4 files changed, 60 insertions, 6 deletions
diff --git a/DEV_NOTES b/DEV_NOTES
index bb80106..41f77a4 100644
--- a/DEV_NOTES
+++ b/DEV_NOTES
@@ -4,13 +4,15 @@ File Summary:
4-sta.py : business logic 4-sta.py : business logic
5-sta_types.py : specifies binary format of sched trace data 5-sta_types.py : specifies binary format of sched trace data
6-sta_output.py : output formatting function(s) 6-sta_output.py : output formatting function(s)
7-run.py : gives an example of how to use sta.py
8-list.py : list of trace files. (you would have to change this file to be
9 point to trace files on the local machine.)
7 10
11To test:
121) Modify list.py to point to trace files on your local machine
132) execute run.py (e.g. run.py > out)
8 14
9Likely next steps: 15Likely next steps:
10- Try to get StParamData working 16- Try to get StParamData working
11- Define convenience comparisons for ordering by earliest time for sort,
12- and lambdas for filtering by job or PID or CPU or whatever
13- and change read_trace to possibly take multiple traces.
14- and /maybe/ allow for saving /loading previously saved traces.
15 17
16 18
diff --git a/list.py b/list.py
new file mode 100644
index 0000000..194a0cb
--- /dev/null
+++ b/list.py
@@ -0,0 +1,14 @@
1full_list = [
2'/home/mollison/sta-alt/traces/st-g6-0.bin',
3'/home/mollison/sta-alt/traces/st-g6-1.bin',
4'/home/mollison/sta-alt/traces/st-g6-2.bin',
5'/home/mollison/sta-alt/traces/st-g6-3.bin',
6'/home/mollison/sta-alt/traces/st-x19-0.bin',
7'/home/mollison/sta-alt/traces/st-x19-1.bin',
8'/home/mollison/sta-alt/traces/st-x19-2.bin',
9'/home/mollison/sta-alt/traces/st-x19-3.bin',
10'/home/mollison/sta-alt/traces/st0.fg',
11'/home/mollison/sta-alt/traces/st1.fg']
12
13list = [
14'/home/mollison/sta-alt/traces/st0.fg']
diff --git a/run.py b/run.py
new file mode 100755
index 0000000..c1eac09
--- /dev/null
+++ b/run.py
@@ -0,0 +1,12 @@
1#!/usr/bin/python3
2
3import sta
4import list
5trace = sta.Trace(list.list)
6#trace.filter("exec_time>8828")
7#trace.filter("job==12")
8#trace.filter("when>2000000000")
9#trace.filter("when<2500000000")
10trace.filter("forced?==True")
11for record in trace.iter:
12 sta.print_record_verbose(record)
diff --git a/sta.py b/sta.py
index 9706704..0354495 100755
--- a/sta.py
+++ b/sta.py
@@ -14,9 +14,14 @@ from sta_types import *
14# Business logic # 14# Business logic #
15################## 15##################
16class Trace: 16class Trace:
17 """Object representing a trace (i.e. set of records)"""
18
17 def __init__(self,files): 19 def __init__(self,files):
20 """Initialize the Trace object with an iterator"""
18 self.iter = self.make_iter(files) 21 self.iter = self.make_iter(files)
22
19 def make_iter(self, files): 23 def make_iter(self, files):
24 """Make the iterator for this Trace object"""
20 for file in files: 25 for file in files:
21 f = open(file,'rb') 26 f = open(file,'rb')
22 while True: 27 while True:
@@ -32,6 +37,27 @@ class Trace:
32 f.close() 37 f.close()
33 break 38 break
34 def filter(self, criteria): 39 def filter(self, criteria):
35 func = eval("lambda x: " + criteria) 40 """Apply a filter to the trace"""
36 self.iter = filter(func, self.iter)
37 41
42 #Determine if they want to filter by >, <, or ==
43 comp = None
44 seps = ['>','<','==']
45 for sep in seps:
46 if criteria.find(sep) > 0:
47 comp = sep
48 if not comp:
49 print("Your filter is invalid: " + criteria)
50 exit()
51
52 #Apply the filter
53 field, comp, value = criteria.partition(comp)
54 test = "rec['" + field + "']" + comp + "int(" + value + ")"
55 def func(rec):
56 try:
57 if eval(test):
58 return True
59 else:
60 return False
61 except KeyError:
62 return False
63 self.iter = filter(func, self.iter)