Skip to content

Commit 99eca18

Browse files
committed
Updated benchmark to consume effectively the iterator
1 parent 7801b53 commit 99eca18

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

logstash-core/benchmarks/src/main/java/org/logstash/benchmark/BufferedTokenizerBenchmark.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838

3939
@Warmup(iterations = 3, time = 100, timeUnit = TimeUnit.MILLISECONDS)
40-
@Measurement(iterations = 10, time = 100, timeUnit = TimeUnit.MILLISECONDS)
40+
@Measurement(iterations = 10, time = 3000, timeUnit = TimeUnit.MILLISECONDS)
4141
@Fork(1)
4242
@BenchmarkMode(Mode.Throughput)
4343
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@@ -66,24 +66,29 @@ public void setUp() {
6666
@Benchmark
6767
public final void onlyOneTokenPerFragment(Blackhole blackhole) {
6868
Iterable<String> tokens = sut.extract(singleTokenPerFragment);
69+
tokens.forEach(blackhole::consume);
6970
blackhole.consume(tokens);
7071
}
7172

7273
@Benchmark
7374
public final void multipleTokenPerFragment(Blackhole blackhole) {
7475
Iterable<String> tokens = sut.extract(multipleTokensPerFragment);
76+
tokens.forEach(blackhole::consume);
7577
blackhole.consume(tokens);
7678
}
7779

7880
@Benchmark
7981
public final void multipleTokensCrossingMultipleFragments(Blackhole blackhole) {
8082
Iterable<String> tokens = sut.extract(multipleTokensSpreadMultipleFragments_1);
83+
tokens.forEach(t -> {});
8184
blackhole.consume(tokens);
8285

8386
tokens = sut.extract(multipleTokensSpreadMultipleFragments_2);
87+
tokens.forEach(t -> {});
8488
blackhole.consume(tokens);
8589

8690
tokens = sut.extract(multipleTokensSpreadMultipleFragments_3);
91+
tokens.forEach(blackhole::consume);
8792
blackhole.consume(tokens);
8893
}
8994
}

0 commit comments

Comments
 (0)