Class that tracks trace/runnable results and produces script output. The output is structured like this: { "traces": [ { "graphs": ["path", "to", "trace", "config"], "units": , "results": [<list of values measured ove
| 174 | |
| 175 | |
| 176 | class ResultTracker(object): |
| 177 | """Class that tracks trace/runnable results and produces script output. |
| 178 | |
| 179 | The output is structured like this: |
| 180 | { |
| 181 | "traces": [ |
| 182 | { |
| 183 | "graphs": ["path", "to", "trace", "config"], |
| 184 | "units": <string describing units, e.g. "ms" or "KB">, |
| 185 | "results": [<list of values measured over several runs>], |
| 186 | "stddev": <stddev of the value if measure by script or ''> |
| 187 | }, |
| 188 | ... |
| 189 | ], |
| 190 | "runnables": [ |
| 191 | { |
| 192 | "graphs": ["path", "to", "runnable", "config"], |
| 193 | "durations": [<list of durations of each runnable run in seconds>], |
| 194 | "timeout": <timeout configured for runnable in seconds>, |
| 195 | }, |
| 196 | ... |
| 197 | ], |
| 198 | "errors": [<list of strings describing errors>], |
| 199 | } |
| 200 | """ |
| 201 | def __init__(self): |
| 202 | self.traces = {} |
| 203 | self.errors = [] |
| 204 | self.runnables = {} |
| 205 | |
| 206 | def AddTraceResult(self, trace, result, stddev): |
| 207 | if trace.name not in self.traces: |
| 208 | self.traces[trace.name] = { |
| 209 | 'graphs': trace.graphs, |
| 210 | 'units': trace.units, |
| 211 | 'results': [result], |
| 212 | 'stddev': stddev or '', |
| 213 | } |
| 214 | else: |
| 215 | existing_entry = self.traces[trace.name] |
| 216 | assert trace.graphs == existing_entry['graphs'] |
| 217 | assert trace.units == existing_entry['units'] |
| 218 | if stddev: |
| 219 | existing_entry['stddev'] = stddev |
| 220 | existing_entry['results'].append(result) |
| 221 | |
| 222 | def TraceHasStdDev(self, trace): |
| 223 | return trace.name in self.traces and self.traces[trace.name]['stddev'] != '' |
| 224 | |
| 225 | def AddError(self, error): |
| 226 | self.errors.append(error) |
| 227 | |
| 228 | def AddRunnableDuration(self, runnable, duration): |
| 229 | """Records a duration of a specific run of the runnable.""" |
| 230 | if runnable.name not in self.runnables: |
| 231 | self.runnables[runnable.name] = { |
| 232 | 'graphs': runnable.graphs, |
| 233 | 'durations': [duration], |
no outgoing calls
no test coverage detected
searching dependent graphs…