mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Better benchmarks values.
``` ❯ benchcmp before.txt after.txt benchmark old ns/op new ns/op delta BenchmarkNewFastRegexMatcher/(foo|bar)-16 2487 2520 +1.33% BenchmarkNewFastRegexMatcher/foo.*-16 8856 4531 -48.84% BenchmarkNewFastRegexMatcher/.*foo-16 25195 6389 -74.64% BenchmarkNewFastRegexMatcher/^.*foo$-16 25626 6253 -75.60% BenchmarkNewFastRegexMatcher/^.+foo$-16 25429 6248 -75.43% BenchmarkNewFastRegexMatcher/.*-16 429707 8439 -98.04% BenchmarkNewFastRegexMatcher/.+-16 380165 8503 -97.76% BenchmarkNewFastRegexMatcher/foo.+-16 8180 4586 -43.94% BenchmarkNewFastRegexMatcher/.+foo-16 25214 6255 -75.19% BenchmarkNewFastRegexMatcher/foo_.+-16 8116 4334 -46.60% BenchmarkNewFastRegexMatcher/foo_.*-16 8354 4287 -48.68% BenchmarkNewFastRegexMatcher/.*foo.*-16 206076 19227 -90.67% BenchmarkNewFastRegexMatcher/.+foo.+-16 208434 18793 -90.98% BenchmarkNewFastRegexMatcher/#00-16 33045 3936 -88.09% BenchmarkNewFastRegexMatcher/(?s:.*)-16 403806 4208 -98.96% BenchmarkNewFastRegexMatcher/(?s:.+)-16 418177 4150 -99.01% BenchmarkNewFastRegexMatcher/(?s:^.*foo$)-16 24452 5661 -76.85% BenchmarkNewFastRegexMatcher/^(?i:foo|oo)|(bar)$-16 48087 23183 -51.79% BenchmarkNewFastRegexMatcher/((.*)(bar|b|buzz)(.+)|foo)$-16 645430 47193 -92.69% BenchmarkNewFastRegexMatcher/^$-16 37244 3912 -89.50% BenchmarkNewFastRegexMatcher/(prometheus|api_prom)_api_v1_.+-16 17205 10006 -41.84% BenchmarkNewFastRegexMatcher/10\.0\.(1|2)\.+-16 6776 7011 +3.47% BenchmarkNewFastRegexMatcher/10\.0\.(1|2).+-16 14792 4674 -68.40% BenchmarkNewFastRegexMatcher/((fo(bar))|.+foo)-16 497007 17410 -96.50% ``` Signed-off-by: Cyril Tovena <cyril.tovena@gmail.com>
This commit is contained in:
parent
715274ec9d
commit
9c33f392e6
|
@ -410,10 +410,10 @@ type anyStringMatcher struct {
|
|||
}
|
||||
|
||||
func (m *anyStringMatcher) Matches(s string) bool {
|
||||
if !m.matchNL && strings.ContainsRune(s, '\n') {
|
||||
if !m.allowEmpty && len(s) == 0 {
|
||||
return false
|
||||
}
|
||||
if !m.allowEmpty && len(s) == 0 {
|
||||
if !m.matchNL && strings.ContainsRune(s, '\n') {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -82,8 +82,14 @@ func TestNewFastRegexMatcher(t *testing.T) {
|
|||
}
|
||||
|
||||
func BenchmarkNewFastRegexMatcher(b *testing.B) {
|
||||
benchValues := append(values,
|
||||
RandStringRunes(128), RandStringRunes(256), RandStringRunes(1024))
|
||||
benchValues := values
|
||||
for _, v := range values {
|
||||
for i := 5; i < 50; i = i + 5 {
|
||||
benchValues = append(benchValues, v+RandStringRunes(i))
|
||||
benchValues = append(benchValues, RandStringRunes(i)+v+RandStringRunes(i))
|
||||
benchValues = append(benchValues, RandStringRunes(i)+v)
|
||||
}
|
||||
}
|
||||
for _, r := range regexes {
|
||||
r := r
|
||||
b.Run(r, func(b *testing.B) {
|
||||
|
|
Loading…
Reference in a new issue