Using defer (prior to stopping timers) to cleanup disruptor.
diff --git a/benchmark-disruptor/writer_await_test.go b/benchmark-disruptor/writer_await_test.go
index f782ac1..3a26e75 100644
--- a/benchmark-disruptor/writer_await_test.go
+++ b/benchmark-disruptor/writer_await_test.go
@@ -13,6 +13,7 @@
WithConsumerGroup(SampleConsumer{&ringBuffer}).
Build()
controller.Start()
+ defer controller.Stop()
writer := controller.Writer()
iterations := int64(b.N)
@@ -29,7 +30,6 @@
}
b.StopTimer()
- controller.Stop()
}
func BenchmarkWriterAwaitMany(b *testing.B) {
ringBuffer := [RingBufferSize]int64{}
@@ -38,6 +38,7 @@
WithConsumerGroup(SampleConsumer{&ringBuffer}).
Build()
controller.Start()
+ defer controller.Stop()
writer := controller.Writer()
iterations := int64(b.N)
@@ -58,5 +59,4 @@
}
b.StopTimer()
- controller.Stop()
}
diff --git a/benchmark-disruptor/writer_reservation_multiple_readers_test.go b/benchmark-disruptor/writer_reservation_multiple_readers_test.go
index 27c97d0..bb52072 100644
--- a/benchmark-disruptor/writer_reservation_multiple_readers_test.go
+++ b/benchmark-disruptor/writer_reservation_multiple_readers_test.go
@@ -1,18 +1,22 @@
package benchmarks
import (
+ "runtime"
"testing"
"github.com/smartystreets/go-disruptor"
)
func BenchmarkWriterReserveOneMultipleReaders(b *testing.B) {
+ runtime.GOMAXPROCS(3)
+ defer runtime.GOMAXPROCS(2)
ringBuffer := [RingBufferSize]int64{}
controller := disruptor.
Configure(RingBufferSize).
WithConsumerGroup(SampleConsumer{&ringBuffer}, SampleConsumer{&ringBuffer}).
Build()
controller.Start()
+ defer controller.Stop()
writer := controller.Writer()
iterations := int64(b.N)
@@ -28,15 +32,18 @@
}
b.StopTimer()
- controller.Stop()
}
+
func BenchmarkWriterReserveManyMultipleReaders(b *testing.B) {
+ runtime.GOMAXPROCS(3)
+ defer runtime.GOMAXPROCS(2)
ringBuffer := [RingBufferSize]int64{}
controller := disruptor.
Configure(RingBufferSize).
WithConsumerGroup(SampleConsumer{&ringBuffer}, SampleConsumer{&ringBuffer}).
Build()
controller.Start()
+ defer controller.Stop()
writer := controller.Writer()
iterations := int64(b.N)
@@ -56,5 +63,4 @@
}
b.StopTimer()
- controller.Stop()
}
diff --git a/benchmark-disruptor/writer_reservation_test.go b/benchmark-disruptor/writer_reservation_test.go
index 98745e7..14719e6 100644
--- a/benchmark-disruptor/writer_reservation_test.go
+++ b/benchmark-disruptor/writer_reservation_test.go
@@ -13,6 +13,7 @@
WithConsumerGroup(SampleConsumer{&ringBuffer}).
Build()
controller.Start()
+ defer controller.Stop()
writer := controller.Writer()
iterations := int64(b.N)
@@ -28,7 +29,6 @@
}
b.StopTimer()
- controller.Stop()
}
func BenchmarkWriterReserveMany(b *testing.B) {
ringBuffer := [RingBufferSize]int64{}
@@ -37,6 +37,7 @@
WithConsumerGroup(SampleConsumer{&ringBuffer}).
Build()
controller.Start()
+ defer controller.Stop()
writer := controller.Writer()
iterations := int64(b.N)
@@ -56,5 +57,4 @@
}
b.StopTimer()
- controller.Stop()
}