forked from smarty-prototypes/go-disruptor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
writer_test.go
53 lines (44 loc) · 1.09 KB
/
writer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package disruptor
import "testing"
func BenchmarkWriterReserve(b *testing.B) {
read, written := NewCursor(), NewCursor()
writer := NewWriter(written, read, 1024)
iterations := int64(b.N)
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(MaxSequenceValue)
for i := int64(0); i < iterations; i++ {
writer.Reserve(1)
}
}
func BenchmarkWriterAwait(b *testing.B) {
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.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)
}
}