Skip to content

Commit 063bb63

Browse files
committed
chore(benchmark): move testing to new file.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
1 parent c420418 commit 063bb63

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

benchmark_test.go

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
}

queue_test.go

-24
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package queue
22

33
import (
4-
"context"
54
"testing"
65
"time"
76

@@ -141,26 +140,3 @@ func TestCloseQueueAfterShutdown(t *testing.T) {
141140
assert.Error(t, err)
142141
assert.Equal(t, ErrQueueShutdown, err)
143142
}
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-
}

0 commit comments

Comments
 (0)