Additional writer tests.
diff --git a/writer_test.go b/writer_test.go
index 2a5b5f0..990f63d 100644
--- a/writer_test.go
+++ b/writer_test.go
@@ -3,29 +3,51 @@
import "testing"
func BenchmarkWriterReserve(b *testing.B) {
+ read, written := NewCursor(), NewCursor()
+ writer := NewWriter(written, read, 1024)
iterations := int64(b.N)
- written, read := NewCursor(), NewCursor()
- writer := NewWriter(written, read, 1024*64)
-
b.ReportAllocs()
b.ResetTimer()
for i := int64(0); i < iterations; i++ {
+ sequence := writer.Reserve(1)
+ read.Store(sequence)
+ }
+}
+
+func BenchmarkWriterNextWrapPoint(b *testing.B) {
+ read, written := NewCursor(), NewCursor()
+ writer := NewWriter(written, read, 1024)
+ iterations := int64(b.N)
+ b.ReportAllocs()
+ b.ResetTimer()
+
+ read.Store(1<<63 - 1)
+ for i := int64(0); i < iterations; i++ {
writer.Reserve(1)
- read.sequence = i
}
}
func BenchmarkWriterAwait(b *testing.B) {
- iterations := int64(b.N)
written, read := NewCursor(), NewCursor()
writer := NewWriter(written, read, 1024*64)
-
+ iterations := int64(b.N)
b.ReportAllocs()
b.ResetTimer()
for i := int64(0); i < iterations; i++ {
writer.Await(i)
- read.sequence = i
+ read.Store(i)
+ }
+}
+
+func BenchmarkWriterCommit(b *testing.B) {
+ writer := NewWriter(NewCursor(), nil, 1024)
+ iterations := int64(b.N)
+ b.ReportAllocs()
+ b.ResetTimer()
+
+ for i := int64(0); i < iterations; i++ {
+ writer.Commit(i, i)
}
}