forked from centrifugal/centrifuge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics_test.go
36 lines (30 loc) · 884 Bytes
/
metrics_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package centrifuge
import (
"strconv"
"testing"
"github.com/centrifugal/protocol"
"github.com/prometheus/client_golang/prometheus"
"github.com/stretchr/testify/require"
)
func BenchmarkTransportMessagesSent(b *testing.B) {
m, err := initMetricsRegistry(prometheus.DefaultRegisterer, "test")
require.NoError(b, err)
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
i := 0
for pb.Next() {
m.incTransportMessagesSent("test", protocol.FrameTypePushPublication, "channel"+strconv.Itoa(i%10), 200)
}
})
}
func BenchmarkTransportMessagesReceived(b *testing.B) {
m, err := initMetricsRegistry(prometheus.DefaultRegisterer, "test")
require.NoError(b, err)
b.ReportAllocs()
b.RunParallel(func(pb *testing.PB) {
i := 0
for pb.Next() {
m.incTransportMessagesReceived("test", protocol.FrameTypePushPublication, "channel"+strconv.Itoa(i%10), 200)
}
})
}