Exemplo n.º 1
0
    def test_speed(self):
        obj = self.obj

        mock = MockReader()
        mock.buffer_scale_idx = '100.0'
        obj.add_listener(mock)

        res = {}
        # current measurements shows ~25K samples/sec
        for cnt in (10000, 25000, 50000):
            for a in range(0, cnt):
                sample = (cnt, "", 1, r(1000), r(1000), r(1000), rc(), err(), '', 0)
                mock.data.append(sample)
            before = time.time()
            for point in mock.datapoints():
                pass
            after = time.time()
            res[cnt] = after - before
            ROOT_LOGGER.info("Times: %s", res)

            while mock.results:
                point = mock.results.pop(0)
                overall = point[DataPoint.CURRENT]['']
                self.assertTrue(len(overall[KPISet.PERCENTILES]) > 0)

        for point in mock.datapoints(True):
            pass
 def __get_datapoint(n):
     point = DataPoint(n)
     overall = point[DataPoint.CURRENT].setdefault('', KPISet())
     overall[KPISet.CONCURRENCY] = r(100)
     overall[KPISet.SAMPLE_COUNT] = int(100 * r(1000))
     overall[KPISet.FAILURES] = overall[KPISet.SAMPLE_COUNT] / 2.0
     overall[KPISet.AVG_RESP_TIME] = r(100)
     overall[KPISet.AVG_CONN_TIME] = overall[KPISet.AVG_RESP_TIME] / 3.0
     overall[KPISet.AVG_LATENCY] = 2.0 * overall[KPISet.AVG_RESP_TIME] / 3.0
     overall[KPISet.PERCENTILES]['25'] = r(10)
     overall[KPISet.PERCENTILES]['50'] = r(20)
     overall[KPISet.PERCENTILES]['75'] = r(30)
     overall[KPISet.PERCENTILES]['90'] = r(40)
     overall[KPISet.PERCENTILES]['99'] = r(50)
     overall[KPISet.PERCENTILES]['100'] = r(100)
     overall[KPISet.RESP_CODES][rc()] = 1
     point[DataPoint.CUMULATIVE][''] = overall
     return point