[TESTS] PromQL: Add benchmark for PreprocessExpr

Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
Bryan Boreham 2025-06-06 15:02:58 +01:00
parent f1c6fab7e1
commit 0339fbd5a3

View File

@ -660,6 +660,15 @@ func BenchmarkParser(b *testing.B) {
} }
}) })
} }
for _, c := range cases {
b.Run("preprocess "+c, func(b *testing.B) {
expr, _ := parser.ParseExpr(c)
start, end := time.Now().Add(-time.Hour), time.Now()
for i := 0; i < b.N; i++ {
promql.PreprocessExpr(expr, start, end)
}
})
}
for _, c := range errCases { for _, c := range errCases {
name := fmt.Sprintf("%s (should fail)", c) name := fmt.Sprintf("%s (should fail)", c)
b.Run(name, func(b *testing.B) { b.Run(name, func(b *testing.B) {