def add_results(self, results): if results is None: return elif isinstance(results, AggregatedCPUMeasurementResults): self.individual_results.extend(results.individual_results) elif isinstance(results, CPUMeasurementResults): self.individual_results.append(results) else: raise MeasurementError("Adding incorrect results.")
def _aggregate_hostcpu_results(self, old, new): if (old is not None and (old.host is not new.host or old.cpu != new.cpu)): raise MeasurementError("Aggregating incompatible CPU Results") new_result = AggregatedCPUMeasurementResults(self, new.host, new.cpu) new_result.add_results(old) new_result.add_results(new) return new_result
def _aggregate_flows(self, old_flow, new_flow): if old_flow is not None and old_flow.flow is not new_flow.flow: raise MeasurementError("Aggregating incompatible Flows") new_result = AggregatedFlowMeasurementResults(measurement=self, flow=new_flow.flow) new_result.add_results(old_flow) new_result.add_results(new_flow) return new_result
def start(self): if len(self._running_measurements) > 0: raise MeasurementError("Measurement already running!") test_flows = self._prepare_test_flows(self.flows) for flow in test_flows: flow.server_job.start(bg=True) for flow in test_flows: flow.client_job.start(bg=True) self._running_measurements = test_flows
def _flows_by_generator(self, flows): result = dict() for flow in flows: if flow.generator in result: result[flow.generator].append(flow) else: result[flow.generator] = [flow] for generator, flows in list(result.items()): for flow in flows: if (flow.duration != flows[0].duration or flow.msg_size != flows[0].msg_size): raise MeasurementError("Flows on the same generator need to have the same duration and msg_size at the moment") return result
def start(self): if len(self._running_measurements) > 0: raise MeasurementError("Measurement already running!") tests = self._prepare_tests(self._flows) result = None for test in tests: test.server_job.start(bg=True) #wait for Trex server to start time.sleep(5) for test in tests: test.client_job.start(bg=True) self._running_measurements = tests
def add_results(self, results): if results is None: return elif isinstance(results, AggregatedFlowMeasurementResults): self.individual_results.extend(results.individual_results) self.generator_results.extend(results.generator_results) self.generator_cpu_stats.extend(results.generator_cpu_stats) self.receiver_results.extend(results.receiver_results) self.receiver_cpu_stats.extend(results.receiver_cpu_stats) elif isinstance(results, FlowMeasurementResults): self.individual_results.append(results) self.generator_results.append(results.generator_results) self.generator_cpu_stats.append(results.generator_cpu_stats) self.receiver_results.append(results.receiver_results) self.receiver_cpu_stats.append(results.receiver_cpu_stats) else: raise MeasurementError("Adding incorrect results.")