diff options
Diffstat (limited to 'sta.py')
-rwxr-xr-x | sta.py | 44 |
1 files changed, 22 insertions, 22 deletions
@@ -67,11 +67,6 @@ class Trace: | |||
67 | return False | 67 | return False |
68 | self.iter = filter(func, self.iter) | 68 | self.iter = filter(func, self.iter) |
69 | 69 | ||
70 | def count(self): | ||
71 | """Return the number of records in the trace""" | ||
72 | return len(list(self.iter)) | ||
73 | |||
74 | #Needs to be tested/finished | ||
75 | def sort(self, key): | 70 | def sort(self, key): |
76 | """Return the records sorted by some key""" | 71 | """Return the records sorted by some key""" |
77 | def sortfunc(record): | 72 | def sortfunc(record): |
@@ -81,6 +76,27 @@ class Trace: | |||
81 | return 0 | 76 | return 0 |
82 | self.iter = sorted(self.iter, key=sortfunc) | 77 | self.iter = sorted(self.iter, key=sortfunc) |
83 | 78 | ||
79 | def print_records(self): | ||
80 | """Prints all records in the trace""" | ||
81 | for record in self.iter: | ||
82 | print(50*'=') | ||
83 | print(get_type(record['type']).message) | ||
84 | for k,v in record.items(): | ||
85 | print(k +":", v) | ||
86 | |||
87 | def print_count(self,verbose=False): | ||
88 | """Prints the number of records in the trace.""" | ||
89 | print("Total Count: " + str(len(self.iter))) | ||
90 | if verbose: | ||
91 | counts = {1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:0} | ||
92 | for record in self.iter: | ||
93 | type = record['type'] | ||
94 | counts[type] += 1 | ||
95 | for key in counts.keys(): | ||
96 | print(get_type(key).__name__ + | ||
97 | ': ' + str(counts[key])) | ||
98 | print("") | ||
99 | |||
84 | 100 | ||
85 | #################################### | 101 | #################################### |
86 | # Types for binary data conversion # | 102 | # Types for binary data conversion # |
@@ -130,7 +146,7 @@ class StSwitchAwayData: | |||
130 | format = 'LI' | 146 | format = 'LI' |
131 | formatStr = struct.Struct(StHeader.format + format) | 147 | formatStr = struct.Struct(StHeader.format + format) |
132 | keys = StHeader.keys + ['when','exec_time'] | 148 | keys = StHeader.keys + ['when','exec_time'] |
133 | message = 'A process was away on a given CPU.' | 149 | message = 'A process was switched away on a given CPU.' |
134 | 150 | ||
135 | class StCompletionData: | 151 | class StCompletionData: |
136 | format = 'L7x?c' | 152 | format = 'L7x?c' |
@@ -163,19 +179,3 @@ def get_type(type_num): | |||
163 | StResumeData,StSysReleaseData] | 179 | StResumeData,StSysReleaseData] |
164 | return types[type_num] | 180 | return types[type_num] |
165 | 181 | ||
166 | |||
167 | #################################### | ||
168 | # Output formatting functions # | ||
169 | #################################### | ||
170 | |||
171 | def print_record_verbose(record): | ||
172 | """Prints a record verbosely, given the record as a dict.""" | ||
173 | print(50*'=') | ||
174 | print(get_type(record['type']).message) | ||
175 | for k,v in record.items(): | ||
176 | print(k +":", v) | ||
177 | |||
178 | def print_record_type(record): | ||
179 | """Prints the type of a record.""" | ||
180 | print(record['type']) | ||
181 | |||