def merge_datapoints(self, max_full_ts): for key in sorted(self.join_buffer.keys(), key=int): if int(key) <= max_full_ts: sec_data = self.join_buffer.pop(key) self.log.debug("Processing complete second: %s", key) point = DataPoint(int(key)) for sid, item in iteritems(sec_data): point.merge_point(self.point_from_locust(key, sid, item)) point.recalculate() yield point
def merge_datapoints(self, max_full_ts): for key in sorted(self.join_buffer.keys(), key=lambda x: int(x)): if int(key) <= max_full_ts: sec_data = self.join_buffer.pop(key) self.log.debug("Processing complete second: %s", key) point = DataPoint(int(key)) for sid, item in iteritems(sec_data): point.merge_point(self.point_from_locust(key, sid, item)) point.recalculate() yield point
def merge_datapoints(self, max_full_ts): reader_id = self.file.name + "@" + str(id(self)) for key in sorted(self.join_buffer.keys(), key=int): if int(key) <= max_full_ts: sec_data = self.join_buffer.pop(key) self.log.debug("Processing complete second: %s", key) point = DataPoint(int(key)) point[DataPoint.SOURCE_ID] = reader_id for sid, item in iteritems(sec_data): point.merge_point(self.point_from_locust(key, sid, item)) point.recalculate() yield point
def test_merging(self): dst = DataPoint(0) src = DataPoint(0) src[DataPoint.CUMULATIVE].setdefault('', KPISet()) src[DataPoint.CUMULATIVE][''].sum_rt = 0.5 src[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT] = 1 dst.merge_point(src) self.assertEquals(0.5, dst[DataPoint.CUMULATIVE][''].sum_rt) self.assertEquals(0.5, dst[DataPoint.CUMULATIVE][''][KPISet.AVG_RESP_TIME]) src[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT] = 3 dst.merge_point(src) self.assertEquals(4, dst[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT]) self.assertEquals(1, dst[DataPoint.CUMULATIVE][''].sum_rt) self.assertEquals(0.25, dst[DataPoint.CUMULATIVE][''][KPISet.AVG_RESP_TIME]) src[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT] = 6 dst.merge_point(src) self.assertEquals(10, dst[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT]) self.assertEquals(1.5, dst[DataPoint.CUMULATIVE][''].sum_rt) self.assertEquals(0.15, dst[DataPoint.CUMULATIVE][''][KPISet.AVG_RESP_TIME])
def test_merging(self): dst = DataPoint(0) src = DataPoint(0) src[DataPoint.CUMULATIVE].setdefault('', KPISet()) src[DataPoint.CUMULATIVE][''].sum_rt = 0.5 src[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT] = 1 dst.merge_point(src) self.assertEquals(0.5, dst[DataPoint.CUMULATIVE][''].sum_rt) self.assertEquals(0.5, dst[DataPoint.CUMULATIVE][''][KPISet.AVG_RESP_TIME]) src[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT] = 3 dst.merge_point(src) self.assertEquals(4, dst[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT]) self.assertEquals(1, dst[DataPoint.CUMULATIVE][''].sum_rt) self.assertEquals(0.25, dst[DataPoint.CUMULATIVE][''][KPISet.AVG_RESP_TIME]) src[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT] = 6 dst.merge_point(src) self.assertEquals(10, dst[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT]) self.assertEquals(1.5, dst[DataPoint.CUMULATIVE][''].sum_rt) self.assertEquals(0.15, dst[DataPoint.CUMULATIVE][''][KPISet.AVG_RESP_TIME])