Skip to content

Commit

Permalink
fix aggregator benchmark
Browse files Browse the repository at this point in the history
```
== warmup ==
1 2.564000169513747e-06
1000 0.0003257179996580817
10000 0.003369195001141634
100000 0.03210452299936151
1000000 0.31846129199948336
10000000 3.215345189999425

== noop ==
1 1.984999471460469e-06
1000 0.00032863300111785065
10000 0.0032671120006853016
100000 0.03219444500064128
1000000 0.32194886400066025
10000000 3.2092841119992954

== sum ==
1 1.1226000424358062e-05
1000 0.000391326000681147
10000 0.0033218999997188803
100000 0.031986795000193524
1000000 0.32090956100000767
10000000 3.2212803769998573

== fake ==
1 4.441999408300035e-06
1000 0.0003171700009261258
10000 0.0033069499986595474
100000 0.03180618599981244
1000000 0.3161616289999074
10000000 3.176653272999829

```
  • Loading branch information
bucko909 committed Aug 21, 2024
1 parent 52b40b2 commit 99a3539
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/carbon/tests/benchmark_aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

from carbon.aggregator.processor import AggregationProcessor, RuleManager
from carbon.aggregator.buffers import BufferManager
from carbon.tests.util import print_stats
from carbon.conf import settings
from carbon import state

Expand Down Expand Up @@ -43,21 +42,23 @@ def _bench_aggregator(name):
buf = None
for n in [1, 1000, 10000, 100000, 1000000, 10000000]:
processor = AggregationProcessor()
processor.process(METRIC, (now, 1))
for x in processor.process(METRIC, (now, 1)):
pass

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

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

buf = BufferManager.buffers.get(METRIC_AGGR)
t = timeit.timeit(_process, number=n)
buf.close()
print_stats(n, t)

if buf:
buf.close()
print(n, t)
print("")


Expand Down

0 comments on commit 99a3539

Please sign in to comment.