Skip to content

Commit

Permalink
chore(benchmark): move testing to new file.
Browse files Browse the repository at this point in the history
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
  • Loading branch information
appleboy committed May 30, 2022
1 parent c420418 commit 063bb63
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
29 changes: 29 additions & 0 deletions benchmark_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package queue

import (
"context"
"testing"
)

func BenchmarkQueueTask(b *testing.B) {
b.ReportAllocs()
q := NewPool(5)
defer q.Release()
for n := 0; n < b.N; n++ {
_ = q.QueueTask(func(context.Context) error {
return nil
})
}
}

func BenchmarkQueue(b *testing.B) {
b.ReportAllocs()
m := &mockMessage{
message: "foo",
}
q := NewPool(5)
defer q.Release()
for n := 0; n < b.N; n++ {
_ = q.Queue(m)
}
}
24 changes: 0 additions & 24 deletions queue_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package queue

import (
"context"
"testing"
"time"

Expand Down Expand Up @@ -141,26 +140,3 @@ func TestCloseQueueAfterShutdown(t *testing.T) {
assert.Error(t, err)
assert.Equal(t, ErrQueueShutdown, err)
}

func BenchmarkQueueTask(b *testing.B) {
b.ReportAllocs()
q := NewPool(5)
defer q.Release()
for n := 0; n < b.N; n++ {
_ = q.QueueTask(func(context.Context) error {
return nil
})
}
}

func BenchmarkQueue(b *testing.B) {
b.ReportAllocs()
m := &mockMessage{
message: "foo",
}
q := NewPool(5)
defer q.Release()
for n := 0; n < b.N; n++ {
_ = q.Queue(m)
}
}

0 comments on commit 063bb63

Please sign in to comment.