This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
bench_test.go
79 lines (76 loc) · 1.74 KB
/
bench_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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"path/filepath"
"strings"
"testing"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
)
func TestBenchmarkConfigFromPath(t *testing.T) {
djangoAll := BenchmarkConfig{
// ID: ...,
// StartTime: ...,
Platform: "testdata/platform/python/django",
PlatformConfig: PlatformConfig{
Target: struct{ Path string }{
Path: "/update?queries=10",
},
RPS: 10,
Duration: "30s",
},
Runs: []RunConfig{
{
Name: "baseline",
NeedsRelay: false,
},
{
Name: "instrumented",
NeedsRelay: true,
},
{
Name: "opentelemetry",
NeedsRelay: true,
},
},
}
djangoInstrumented := BenchmarkConfig{
// ID: ...,
// StartTime: ...,
Platform: "testdata/platform/python/django",
PlatformConfig: PlatformConfig{
Target: struct{ Path string }{
Path: "/update?queries=10",
},
RPS: 10,
Duration: "30s",
},
Runs: []RunConfig{
{
Name: "instrumented",
NeedsRelay: true,
},
},
}
tests := []struct {
Path string
Want BenchmarkConfig
}{
{"testdata/platform/python/django", djangoAll},
{"testdata/platform/python/django/instrumented", djangoInstrumented},
// ensure trailing slash makes no difference
{"testdata/platform/python/django/", djangoAll},
{"testdata/platform/python/django/instrumented/", djangoInstrumented},
}
opts := cmpopts.IgnoreFields(BenchmarkConfig{}, "ID", "StartTime")
for _, tt := range tests {
tt := tt
name := strings.TrimPrefix(tt.Path, "testdata/platform/")
t.Run(name, func(t *testing.T) {
want := tt.Want
got := BenchmarkConfigFromPath(filepath.FromSlash(tt.Path))
if diff := cmp.Diff(want, got, opts); diff != "" {
t.Errorf("(-want +got):\n%s", diff)
}
})
}
}