mirror of
				https://github.com/prometheus/prometheus.git
				synced 2025-11-04 10:21:02 +01:00 
			
		
		
		
	Merge pull request #17212 from bboreham/no-simplify
[PERF] Regex: stop calling Simplify
This commit is contained in:
		
						commit
						968d722bb2
					
				@ -225,6 +225,13 @@ func BenchmarkNewMatcher(b *testing.B) {
 | 
				
			|||||||
			NewMatcher(MatchRegexp, "foo", "bar")
 | 
								NewMatcher(MatchRegexp, "foo", "bar")
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
						b.Run("complex regex", func(b *testing.B) {
 | 
				
			||||||
 | 
							b.ReportAllocs()
 | 
				
			||||||
 | 
							b.ResetTimer()
 | 
				
			||||||
 | 
							for i := 0; i <= b.N; i++ {
 | 
				
			||||||
 | 
								NewMatcher(MatchRegexp, "foo", "((.*)(bar|b|buzz)(.+)|foo){10}")
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func BenchmarkMatcher_String(b *testing.B) {
 | 
					func BenchmarkMatcher_String(b *testing.B) {
 | 
				
			||||||
 | 
				
			|||||||
@ -67,8 +67,6 @@ func NewFastRegexMatcher(v string) (*FastRegexMatcher, error) {
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		// Simplify the syntax tree to run faster.
 | 
					 | 
				
			||||||
		parsed = parsed.Simplify()
 | 
					 | 
				
			||||||
		m.re, err = regexp.Compile("^(?s:" + parsed.String() + ")$")
 | 
							m.re, err = regexp.Compile("^(?s:" + parsed.String() + ")$")
 | 
				
			||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return nil, err
 | 
								return nil, err
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user