提交 ecd0a9c6 编写于 作者: B Brian Brazil

web: Add benchmark for respond()

上级 4cb8f6c2
......@@ -853,3 +853,26 @@ func TestOptionsMethod(t *testing.T) {
}
}
}
// This is a global to avoid the benchmark being optimized away.
var testResponseWriter = httptest.ResponseRecorder{}
func BenchmarkRespond(b *testing.B) {
b.ReportAllocs()
points := []promql.Point{}
for i := 0; i < 10000; i++ {
points = append(points, promql.Point{V: float64(i * 1000000), T: int64(i)})
}
response := &queryData{
ResultType: promql.ValueTypeMatrix,
Result: promql.Matrix{
promql.Series{
Points: points,
Metric: nil,
},
},
}
for n := 0; n < b.N; n++ {
respond(&testResponseWriter, response)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册