MCPcopy Index your code
hub / github.com/cortexproject/cortex / Benchmark_Compression

Function Benchmark_Compression

pkg/api/api_test.go:111–214  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

109}
110
111func Benchmark_Compression(b *testing.B) {
112 client := &http.Client{
113 Transport: &http.Transport{
114 DisableCompression: true,
115 },
116 }
117
118 cfg := Config{
119 ResponseCompression: true,
120 }
121
122 cases := map[string]struct {
123 enc string
124 numberOfLabels int
125 }{
126 "gzip-10-labels": {
127 enc: gzipEncoding,
128 numberOfLabels: 10,
129 },
130 "gzip-100-labels": {
131 enc: gzipEncoding,
132 numberOfLabels: 100,
133 },
134 "gzip-1K-labels": {
135 enc: gzipEncoding,
136 numberOfLabels: 1000,
137 },
138 "gzip-10K-labels": {
139 enc: gzipEncoding,
140 numberOfLabels: 10000,
141 },
142 "gzip-100K-labels": {
143 enc: gzipEncoding,
144 numberOfLabels: 100000,
145 },
146 "gzip-1M-labels": {
147 enc: gzipEncoding,
148 numberOfLabels: 1000000,
149 },
150 }
151
152 for name, tc := range cases {
153 b.Run(name, func(b *testing.B) {
154 serverCfg := server.Config{
155 HTTPListenNetwork: server.DefaultNetwork,
156 HTTPListenPort: 8080,
157 Registerer: prometheus.NewRegistry(),
158 }
159
160 server, err := server.New(serverCfg)
161 require.NoError(b, err)
162 api, err := New(cfg, serverCfg, server, &FakeLogger{})
163 require.NoError(b, err)
164
165 labels := labels.ScratchBuilder{}
166
167 for i := 0; i < tc.numberOfLabels; i++ {
168 labels.Add(fmt.Sprintf("Name%v", i), fmt.Sprintf("Value%v", i))

Callers

nothing calls this directly

Calls 13

RegisterRouteMethod · 0.80
ShutdownMethod · 0.80
LoopMethod · 0.80
NewFunction · 0.70
RunMethod · 0.65
StringMethod · 0.65
SetMethod · 0.65
DoMethod · 0.65
AddMethod · 0.45
MarshalMethod · 0.45
LabelsMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected