From fc6b2d91934f20dda7f16f3b584c301e11d17f92 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Sun, 12 Oct 2014 14:54:36 +0200 Subject: [PATCH] Ignore matcher benchmark --- internal/ignore/ignore_test.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/internal/ignore/ignore_test.go b/internal/ignore/ignore_test.go index 2c826069..d5cace3a 100644 --- a/internal/ignore/ignore_test.go +++ b/internal/ignore/ignore_test.go @@ -162,3 +162,29 @@ func TestCommentsAndBlankLines(t *testing.T) { t.Errorf("Expected no patterns") } } + +var result bool + +func BenchmarkMatch(b *testing.B) { + stignore := ` +.frog +.frog* +.frogfox +.whale +.whale/* +.dolphin +.dolphin/* +~ferret~.* +.ferret.* +flamingo.* +flamingo +*.crow +*.crow + ` + pats, _ := ignore.Parse(bytes.NewBufferString(stignore), ".stignore") + + b.ResetTimer() + for i := 0; i < b.N; i++ { + result = pats.Match("filename") + } +}