File tree 2 files changed +29
-24
lines changed
2 files changed +29
-24
lines changed Original file line number Diff line number Diff line change
1
+ package queue
2
+
3
+ import (
4
+ "context"
5
+ "testing"
6
+ )
7
+
8
+ func BenchmarkQueueTask (b * testing.B ) {
9
+ b .ReportAllocs ()
10
+ q := NewPool (5 )
11
+ defer q .Release ()
12
+ for n := 0 ; n < b .N ; n ++ {
13
+ _ = q .QueueTask (func (context.Context ) error {
14
+ return nil
15
+ })
16
+ }
17
+ }
18
+
19
+ func BenchmarkQueue (b * testing.B ) {
20
+ b .ReportAllocs ()
21
+ m := & mockMessage {
22
+ message : "foo" ,
23
+ }
24
+ q := NewPool (5 )
25
+ defer q .Release ()
26
+ for n := 0 ; n < b .N ; n ++ {
27
+ _ = q .Queue (m )
28
+ }
29
+ }
Original file line number Diff line number Diff line change 1
1
package queue
2
2
3
3
import (
4
- "context"
5
4
"testing"
6
5
"time"
7
6
@@ -141,26 +140,3 @@ func TestCloseQueueAfterShutdown(t *testing.T) {
141
140
assert .Error (t , err )
142
141
assert .Equal (t , ErrQueueShutdown , err )
143
142
}
144
-
145
- func BenchmarkQueueTask (b * testing.B ) {
146
- b .ReportAllocs ()
147
- q := NewPool (5 )
148
- defer q .Release ()
149
- for n := 0 ; n < b .N ; n ++ {
150
- _ = q .QueueTask (func (context.Context ) error {
151
- return nil
152
- })
153
- }
154
- }
155
-
156
- func BenchmarkQueue (b * testing.B ) {
157
- b .ReportAllocs ()
158
- m := & mockMessage {
159
- message : "foo" ,
160
- }
161
- q := NewPool (5 )
162
- defer q .Release ()
163
- for n := 0 ; n < b .N ; n ++ {
164
- _ = q .Queue (m )
165
- }
166
- }
You can’t perform that action at this time.
0 commit comments