Added new benchmarks and updated README accordingly.
diff --git a/README.md b/README.md
index caace74..1057901 100644
--- a/README.md
+++ b/README.md
@@ -35,8 +35,8 @@
Disruptor: Writer, Await Many | 1.0 ns/op
Disruptor: SharedWriter, Reserve One | 13.6 ns/op
Disruptor: SharedWriter, Reserve Many | 2.5 ns/op
-Disruptor: SharedWriter, Reserve One, Contended Write | nn.n ns/op
-Disruptor: SharedWriter, Reserve Many, Contended Write | nn.n ns/op
+Disruptor: SharedWriter, Reserve One, Contended Write | 56.9 ns/op
+Disruptor: SharedWriter, Reserve Many, Contended Write | 3.5 ns/op
When In Doubt, Use Channels
----------------------------
diff --git a/benchmark-disruptor/shared_writer_contended_write_test.go b/benchmark-disruptor/shared_writer_contended_write_test.go
new file mode 100644
index 0000000..08b6f70
--- /dev/null
+++ b/benchmark-disruptor/shared_writer_contended_write_test.go
@@ -0,0 +1,93 @@
+package benchmarks
+
+import (
+ "runtime"
+ "testing"
+
+ "github.com/smartystreets/go-disruptor"
+)
+
+func BenchmarkSharedWriterReserveOneContendedWrite(b *testing.B) {
+ runtime.GOMAXPROCS(3)
+ defer runtime.GOMAXPROCS(2)
+
+ ringBuffer := [RingBufferSize]int64{}
+ controller := disruptor.
+ Configure(RingBufferSize).
+ WithConsumerGroup(SampleConsumer{&ringBuffer}).
+ BuildShared()
+ controller.Start()
+ defer controller.Stop()
+ writer := controller.Writer()
+
+ iterations := int64(b.N)
+ b.ReportAllocs()
+ b.ResetTimer()
+
+ go func() {
+ sequence := disruptor.InitialSequenceValue
+ for sequence < iterations {
+ sequence = writer.Reserve(ReserveOne)
+ ringBuffer[sequence&RingBufferMask] = sequence
+ writer.Commit(sequence, sequence)
+ }
+ }()
+
+ sequence := disruptor.InitialSequenceValue
+ for sequence < iterations {
+ sequence = writer.Reserve(ReserveOne)
+ ringBuffer[sequence&RingBufferMask] = sequence
+ writer.Commit(sequence, sequence)
+ }
+
+ b.StopTimer()
+}
+
+func BenchmarkSharedWriterReserveManyContendedWrite(b *testing.B) {
+ runtime.GOMAXPROCS(3)
+ defer runtime.GOMAXPROCS(2)
+
+ ringBuffer := [RingBufferSize]int64{}
+ controller := disruptor.
+ Configure(RingBufferSize).
+ WithConsumerGroup(noopConsumer{}).
+ BuildShared()
+ controller.Start()
+ defer controller.Stop()
+ writer := controller.Writer()
+
+ iterations := int64(b.N)
+ b.ReportAllocs()
+ b.ResetTimer()
+
+ go func() {
+ previous, current := disruptor.InitialSequenceValue, disruptor.InitialSequenceValue
+ for current < iterations {
+ current = writer.Reserve(ReserveMany)
+
+ for i := previous + 1; i <= current; i++ {
+ ringBuffer[i&RingBufferMask] = i
+ }
+
+ writer.Commit(previous+1, current)
+ previous = current
+ }
+ }()
+ previous, current := disruptor.InitialSequenceValue, disruptor.InitialSequenceValue
+ for current < iterations {
+ current = writer.Reserve(ReserveMany)
+
+ for i := previous + 1; i <= current; i++ {
+ ringBuffer[i&RingBufferMask] = i
+ }
+
+ writer.Commit(previous+1, current)
+ previous = current
+ }
+
+ b.StopTimer()
+}
+
+type noopConsumer struct{}
+
+func (this noopConsumer) Consume(lower, upper int64) {}