Пример #1
0
 def setUp(self):
     self.sample_aggregation_rule = AggregationRule(r'^carbon.foo',
                                                    r'carbon.foo.sum',
                                                    'sum', 1)
     self.sample_overwriting_aggregation_rule = \
         AggregationRule(r'^carbon.foo', r'carbon.foo', 'sum', 1)
     self.processor = AggregationProcessor()
Пример #2
0
def _bench_aggregator(name):
    print("== %s ==" % name)
    max_intervals = settings['MAX_AGGREGATION_INTERVALS']
    now = time.time() - (max_intervals * FREQUENCY)

    buf = None
    for n in [1, 1000, 10000, 100000, 1000000, 10000000]:
        processor = AggregationProcessor()
        processor.process(METRIC, (now, 1))

        def _process():
            processor.process(METRIC, (now + _process.i, 1))
            if (_process.i % FREQUENCY) == 0 and buf is not None:
                buf.compute_values()
            _process.i += 1

        _process.i = 0

        if buf is None:
            buf = BufferManager.get_buffer(METRIC_AGGR, 1, None)

        t = timeit.timeit(_process, number=n)
        buf.close()
        print_stats(n, t)
    print("")