Skip to content

Instantly share code, notes, and snippets.

@lasiar
Created June 3, 2023 23:59
Show Gist options
  • Save lasiar/c089288acfab500defda4821f24831cc to your computer and use it in GitHub Desktop.
Save lasiar/c089288acfab500defda4821f24831cc to your computer and use it in GitHub Desktop.
func BenchmarkClimate(b *testing.B) {
issues := []result.Issue{
{
FromLinter: "linter-a",
Severity: "warning",
Text: "some issue",
Pos: token.Position{
Filename: "path/to/filea.go",
Offset: 2,
Line: 10,
Column: 4,
},
},
{
FromLinter: "linter-b",
Severity: "error",
Text: "another issue",
SourceLines: []string{
"func foo() {",
"\tfmt.Println(\"bar\")",
"}",
},
Pos: token.Position{
Filename: "path/to/fileb.go",
Offset: 5,
Line: 300,
Column: 9,
},
},
{
FromLinter: "linter-c",
Text: "issue c",
SourceLines: []string{
"func foo() {",
"\tfmt.Println(\"ccc\")",
"}",
},
Pos: token.Position{
Filename: "path/to/filec.go",
Offset: 6,
Line: 200,
Column: 2,
},
},
}
buf := new(bytes.Buffer)
printer := NewCodeClimate(buf)
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
printer.Print(issues)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment