mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-19 15:30:17 +00:00
lib/storage: add benchmarks for regexp filter match / mismatch
These benchmarks allow estimate the performance of regexp filters in promql
This commit is contained in:
parent
559dd03181
commit
4ed63d033a
1 changed files with 29 additions and 0 deletions
|
@ -3,6 +3,7 @@ package storage
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"testing"
|
"testing"
|
||||||
|
@ -11,6 +12,34 @@ import (
|
||||||
"github.com/VictoriaMetrics/VictoriaMetrics/lib/workingsetcache"
|
"github.com/VictoriaMetrics/VictoriaMetrics/lib/workingsetcache"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func BenchmarkRegexpFilterMatch(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
|
re := regexp.MustCompile(`.*foo-bar-baz.*`)
|
||||||
|
b := []byte("fdsffd foo-bar-baz assd fdsfad dasf dsa")
|
||||||
|
for pb.Next() {
|
||||||
|
if !re.Match(b) {
|
||||||
|
panic("BUG: regexp must match!")
|
||||||
|
}
|
||||||
|
b[0]++
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkRegexpFilterMismatch(b *testing.B) {
|
||||||
|
b.ReportAllocs()
|
||||||
|
b.RunParallel(func(pb *testing.PB) {
|
||||||
|
re := regexp.MustCompile(`.*foo-bar-baz.*`)
|
||||||
|
b := []byte("fdsffd foo-bar sfddsf assd nmn,mfdsdsakj")
|
||||||
|
for pb.Next() {
|
||||||
|
if re.Match(b) {
|
||||||
|
panic("BUG: regexp mustn't match!")
|
||||||
|
}
|
||||||
|
b[0]++
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
func BenchmarkIndexDBAddTSIDs(b *testing.B) {
|
func BenchmarkIndexDBAddTSIDs(b *testing.B) {
|
||||||
const recordsPerLoop = 1e3
|
const recordsPerLoop = 1e3
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue