File tree 1 file changed +17
-0
lines changed
src/jmh/java/com/lmax/disruptor
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 9
9
import org .openjdk .jmh .annotations .BenchmarkMode ;
10
10
import org .openjdk .jmh .annotations .Fork ;
11
11
import org .openjdk .jmh .annotations .Mode ;
12
+ import org .openjdk .jmh .annotations .OperationsPerInvocation ;
12
13
import org .openjdk .jmh .annotations .OutputTimeUnit ;
13
14
import org .openjdk .jmh .annotations .Scope ;
14
15
import org .openjdk .jmh .annotations .Setup ;
@@ -32,6 +33,7 @@ public class MultiProducerSingleConsumer
32
33
private RingBuffer <SimpleEvent > ringBuffer ;
33
34
private Disruptor <SimpleEvent > disruptor ;
34
35
private static final int BIG_BUFFER = 1 << 22 ;
36
+ private static final int BATCH_SIZE = 100 ;
35
37
36
38
@ Setup
37
39
public void setup (final Blackhole bh )
@@ -57,6 +59,21 @@ public void producing()
57
59
ringBuffer .publish (sequence );
58
60
}
59
61
62
+ @ Benchmark
63
+ @ Threads (4 )
64
+ @ OperationsPerInvocation (BATCH_SIZE )
65
+ public void producingBatch ()
66
+ {
67
+ long hi = ringBuffer .next (BATCH_SIZE );
68
+ long lo = hi - (BATCH_SIZE - 1 );
69
+ for (long sequence = lo ; sequence <= hi ; sequence ++)
70
+ {
71
+ SimpleEvent simpleEvent = ringBuffer .get (sequence );
72
+ simpleEvent .setValue (0 );
73
+ }
74
+ ringBuffer .publish (lo , hi );
75
+ }
76
+
60
77
@ TearDown
61
78
public void tearDown ()
62
79
{
You can’t perform that action at this time.
0 commit comments