MCPcopy Create free account
hub / github.com/conventionalcommit/commitlint / BenchmarkParseAndLint

Function BenchmarkParseAndLint

test/lint_bench_test.go:12–39  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

10var lintResult *lint.Result
11
12func BenchmarkParseAndLint(b *testing.B) {
13 linter, err := config.NewLinter(config.NewDefault())
14 if err != nil {
15 b.Fatal(err)
16 }
17 for _, tt := range []struct {
18 name, input string
19 invalid bool
20 }{
21 {"header", "feat: expose records", false},
22 {"body", "feat: expose records\n\nRetain records.", false},
23 {"footers", "feat: expose records\n\nRetain records.\n\nRefs #9", false},
24 {"recovery", " unknown:reload\nBody text.", true},
25 } {
26 b.Run(tt.name, func(b *testing.B) {
27 b.ReportAllocs()
28 for i := 0; i < b.N; i++ {
29 lintResult, err = linter.ParseAndLint(tt.input)
30 if err != nil {
31 b.Fatal(err)
32 }
33 }
34 if (len(lintResult.Issues()) > 0) != tt.invalid {
35 b.Fatal("incorrect lint result")
36 }
37 })
38 }
39}

Callers

nothing calls this directly

Calls 4

ParseAndLintMethod · 0.95
NewLinterFunction · 0.92
NewDefaultFunction · 0.92
IssuesMethod · 0.80

Tested by

no test coverage detected