File tree 2 files changed +53
-0
lines changed
2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 58
58
- name : Run Tests
59
59
run : |
60
60
go test -v -covermode=atomic -coverprofile=coverage.out
61
+
62
+ - name : Run Benchmark
63
+ run : |
61
64
go test -v -run=^$ -benchmem -bench .
62
65
63
66
- name : Upload coverage to Codecov
Original file line number Diff line number Diff line change @@ -3,6 +3,10 @@ package queue
3
3
import (
4
4
"context"
5
5
"testing"
6
+ "time"
7
+
8
+ "github.com/golang-queue/queue/core"
9
+ "github.com/golang-queue/queue/job"
6
10
)
7
11
8
12
func BenchmarkQueueTask (b * testing.B ) {
@@ -27,3 +31,49 @@ func BenchmarkQueue(b *testing.B) {
27
31
_ = q .Queue (m )
28
32
}
29
33
}
34
+
35
+ func BenchmarkConsumerPayload (b * testing.B ) {
36
+ b .ReportAllocs ()
37
+
38
+ task := & job.Message {
39
+ Timeout : 100 * time .Millisecond ,
40
+ Payload : []byte (`{"timeout":3600000000000}` ),
41
+ }
42
+ w := NewConsumer (
43
+ WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
44
+ return nil
45
+ }),
46
+ )
47
+
48
+ q , _ := NewQueue (
49
+ WithWorker (w ),
50
+ )
51
+
52
+ for n := 0 ; n < b .N ; n ++ {
53
+ _ = q .run (task )
54
+ }
55
+ }
56
+
57
+ func BenchmarkConsumerTask (b * testing.B ) {
58
+ b .ReportAllocs ()
59
+
60
+ task := & job.Message {
61
+ Timeout : 100 * time .Millisecond ,
62
+ Task : func (_ context.Context ) error {
63
+ return nil
64
+ },
65
+ }
66
+ w := NewConsumer (
67
+ WithFn (func (ctx context.Context , m core.QueuedMessage ) error {
68
+ return nil
69
+ }),
70
+ )
71
+
72
+ q , _ := NewQueue (
73
+ WithWorker (w ),
74
+ )
75
+
76
+ for n := 0 ; n < b .N ; n ++ {
77
+ _ = q .run (task )
78
+ }
79
+ }
You can’t perform that action at this time.
0 commit comments