-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
56 lines (44 loc) · 1.22 KB
/
main_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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package main
import (
"github.com/penguin-statistics/widget-backend/config"
"github.com/penguin-statistics/widget-backend/controller/matrix"
"github.com/penguin-statistics/widget-backend/controller/meta"
"github.com/penguin-statistics/widget-backend/response"
"testing"
)
var Controllers *meta.Collection
var Render *response.Assembler
func init() {
Controllers = meta.NewCollection()
Render = response.New(Controllers, config.C.Static.Widget.Root)
}
func BenchmarkStage(b *testing.B) {
query := &matrix.Query{Server: "CN", StageID: "main_01-07"}
for i := 0; i < b.N; i++ {
records, err := Controllers.Matrix.Query(query)
if err != nil {
b.Error(err)
}
Render.MarshalMatrix(records, query)
}
}
func BenchmarkItem(b *testing.B) {
query := &matrix.Query{Server: "CN", ItemID: "30012"}
for i := 0; i < b.N; i++ {
records, err := Controllers.Matrix.Query(query)
if err != nil {
b.Error(err)
}
Render.MarshalMatrix(records, query)
}
}
func BenchmarkExact(b *testing.B) {
query := &matrix.Query{Server: "CN", StageID: "main_01-07", ItemID: "30012"}
for i := 0; i < b.N; i++ {
records, err := Controllers.Matrix.Query(query)
if err != nil {
b.Error(err)
}
Render.MarshalMatrix(records, query)
}
}