mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
web: Add benchmark for respond()
This commit is contained in:
parent
4cb8f6c260
commit
ecd0a9c6ba
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue