Skip to content

Commit a6a0768

Browse files
committed
chore(testing): try sub benchmark
1 parent 5ef37bf commit a6a0768

File tree

1 file changed

+40
-34
lines changed

1 file changed

+40
-34
lines changed

benchmark_test.go

+40-34
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func testQueue(b *testing.B, pool testqueue) {
7171
}
7272
}
7373

74-
func testQueueAndRequest(b *testing.B, pool testqueue) {
74+
func testEnqueueAndDequeue(b *testing.B, pool testqueue) {
7575
message := job.NewTask(func(context.Context) error {
7676
return nil
7777
},
@@ -94,50 +94,56 @@ func testQueueAndRequest(b *testing.B, pool testqueue) {
9494
result = m
9595
}
9696

97-
func BenchmarkQueueAndRequestChannel(b *testing.B) {
98-
testQueueAndRequest(b, ch.NewConsumer(b.N*count))
99-
}
97+
func BenchmarkEnqueueAndDequeue(b *testing.B) {
98+
b.Run("InternalChannel", func(b *testing.B) {
99+
testEnqueueAndDequeue(b, ch.NewConsumer(b.N*count))
100+
})
100101

101-
func BenchmarkQueueAndRequestDoublyLinked(b *testing.B) {
102-
testQueueAndRequest(b, dl.NewDoublyLinked(b.N*count))
103-
}
102+
b.Run("DoublyLinked", func(b *testing.B) {
103+
testEnqueueAndDequeue(b, dl.NewDoublyLinked(b.N*count))
104+
})
104105

105-
func BenchmarkQueueAndRequestCircularBuffer(b *testing.B) {
106-
testQueueAndRequest(b, cb.NewCircularBuffer(b.N*count))
107-
}
106+
b.Run("CircularBuffer", func(b *testing.B) {
107+
testEnqueueAndDequeue(b, cb.NewCircularBuffer(b.N*count))
108+
})
108109

109-
func BenchmarkQueueAndRequestRingBuffer(b *testing.B) {
110-
testQueueAndRequest(b, rb.NewConsumer(b.N*count))
110+
b.Run("RingBuffer", func(b *testing.B) {
111+
testEnqueueAndDequeue(b, rb.NewConsumer(b.N*count))
112+
})
111113
}
112114

113-
func BenchmarkQueueChannel(b *testing.B) {
114-
testQueue(b, ch.NewConsumer(b.N*count))
115-
}
115+
func BenchmarkEnqueue(b *testing.B) {
116+
b.Run("InternalChannel", func(b *testing.B) {
117+
testQueue(b, ch.NewConsumer(b.N*count))
118+
})
116119

117-
func BenchmarkQueueCircularBuffer(b *testing.B) {
118-
testQueue(b, cb.NewCircularBuffer(b.N*count))
119-
}
120+
b.Run("DoublyLinked", func(b *testing.B) {
121+
testQueue(b, dl.NewDoublyLinked(b.N*count))
122+
})
120123

121-
func BenchmarkQueueRingBuffer(b *testing.B) {
122-
testQueue(b, rb.NewConsumer(b.N*count))
123-
}
124+
b.Run("CircularBuffer", func(b *testing.B) {
125+
testQueue(b, cb.NewCircularBuffer(b.N*count))
126+
})
124127

125-
func BenchmarkQueueDoublyLinked(b *testing.B) {
126-
testQueue(b, dl.NewDoublyLinked(b.N*count))
128+
b.Run("RingBuffer", func(b *testing.B) {
129+
testQueue(b, rb.NewConsumer(b.N*count))
130+
})
127131
}
128132

129-
func BenchmarkDeQueueWithChannel(b *testing.B) {
130-
testDeQueue(b, ch.NewConsumer(b.N*count))
131-
}
133+
func BenchmarkDequeue(b *testing.B) {
134+
b.Run("InternalChannel", func(b *testing.B) {
135+
testDeQueue(b, ch.NewConsumer(b.N*count))
136+
})
132137

133-
func BenchmarkDeQueueWithRingBuffer(b *testing.B) {
134-
testDeQueue(b, rb.NewConsumer(b.N*count))
135-
}
138+
b.Run("DoublyLinked", func(b *testing.B) {
139+
testDeQueue(b, dl.NewDoublyLinked(b.N*count))
140+
})
136141

137-
func BenchmarkDeQueueWithDoublyLinked(b *testing.B) {
138-
testDeQueue(b, dl.NewDoublyLinked(b.N*count))
139-
}
142+
b.Run("CircularBuffer", func(b *testing.B) {
143+
testDeQueue(b, cb.NewCircularBuffer(b.N*count))
144+
})
140145

141-
func BenchmarkDeQueueWithCircularBuffer(b *testing.B) {
142-
testDeQueue(b, cb.NewCircularBuffer(b.N*count))
146+
b.Run("RingBuffer", func(b *testing.B) {
147+
testDeQueue(b, rb.NewConsumer(b.N*count))
148+
})
143149
}

0 commit comments

Comments
 (0)