summaryrefslogtreecommitdiffstats
path: root/unit_trace/trace_reader.py
diff options
context:
space:
mode:
Diffstat (limited to 'unit_trace/trace_reader.py')
-rw-r--r--unit_trace/trace_reader.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/unit_trace/trace_reader.py b/unit_trace/trace_reader.py
index 44a3c75..e1d2095 100644
--- a/unit_trace/trace_reader.py
+++ b/unit_trace/trace_reader.py
@@ -5,7 +5,7 @@
5# trace_reader(files) returns an iterator which produces records 5# trace_reader(files) returns an iterator which produces records
6# in order from the files given. (the param is a list of files.) 6# in order from the files given. (the param is a list of files.)
7# 7#
8# Each record is just a Python object. It is guaranteed to have the following 8# Each record is just a Python object. It is guaranteed to have the following
9# attributes: 9# attributes:
10# - 'pid': pid of the task 10# - 'pid': pid of the task
11# - 'job': job number for that task 11# - 'job': job number for that task
@@ -66,7 +66,7 @@ def trace_reader(files):
66 # overwhelmingly probably. 66 # overwhelmingly probably.
67 for x in range(0,len(file_iter_buff)): 67 for x in range(0,len(file_iter_buff)):
68 for y in range(0,100): 68 for y in range(0,100):
69 file_iter_buff[x].append(file_iters[x].next()) 69 file_iter_buff[x].append(file_iters[x].next())
70 for x in range(0,len(file_iter_buff)): 70 for x in range(0,len(file_iter_buff)):
71 file_iter_buff[x] = sorted(file_iter_buff[x],key=lambda rec: rec.when) 71 file_iter_buff[x] = sorted(file_iter_buff[x],key=lambda rec: rec.when)
72 72
@@ -110,7 +110,7 @@ def trace_reader(files):
110 last_time = earliest.when 110 last_time = earliest.when
111 111
112 # Yield the record 112 # Yield the record
113 yield earliest 113 yield earliest
114 114
115############################################################################### 115###############################################################################
116# Private functions 116# Private functions
@@ -123,11 +123,11 @@ def _get_file_iter(file):
123 data = f.read(RECORD_HEAD_SIZE) 123 data = f.read(RECORD_HEAD_SIZE)
124 try: 124 try:
125 type_num = struct.unpack_from('b',data)[0] 125 type_num = struct.unpack_from('b',data)[0]
126 except struct.error: 126 except struct.error:
127 break #We read to the end of the file 127 break #We read to the end of the file
128 type = _get_type(type_num) 128 type = _get_type(type_num)
129 try: 129 try:
130 values = struct.unpack_from(StHeader.format + 130 values = struct.unpack_from(StHeader.format +
131 type.format,data) 131 type.format,data)
132 record_dict = dict(zip(type.keys,values)) 132 record_dict = dict(zip(type.keys,values))
133 except struct.error: 133 except struct.error:
@@ -157,7 +157,7 @@ def _dict2obj(d):
157 o = Obj() 157 o = Obj()
158 for key in d.keys(): 158 for key in d.keys():
159 o.__dict__[key] = d[key] 159 o.__dict__[key] = d[key]
160 return o 160 return o
161 161
162############################################################################### 162###############################################################################
163# Trace record data types and accessor functions 163# Trace record data types and accessor functions
@@ -183,7 +183,7 @@ class StNameData:
183 keys = StHeader.keys + ['name'] 183 keys = StHeader.keys + ['name']
184 message = 'The name of the executable of this process.' 184 message = 'The name of the executable of this process.'
185 185
186class StParamData: 186class StParamData:
187 format = 'IIIc' 187 format = 'IIIc'
188 formatStr = struct.Struct(StHeader.format + format) 188 formatStr = struct.Struct(StHeader.format + format)
189 keys = StHeader.keys + ['wcet','period','phase','partition'] 189 keys = StHeader.keys + ['wcet','period','phase','partition']
@@ -195,7 +195,7 @@ class StReleaseData:
195 keys = StHeader.keys + ['when','deadline'] 195 keys = StHeader.keys + ['when','deadline']
196 message = 'A job was/is going to be released.' 196 message = 'A job was/is going to be released.'
197 197
198#Not yet used by Sched Trace 198#Not yet used by Sched Trace
199class StAssignedData: 199class StAssignedData:
200 format = 'Qc' 200 format = 'Qc'
201 formatStr = struct.Struct(StHeader.format + format) 201 formatStr = struct.Struct(StHeader.format + format)