@@ -16,7 +16,6 @@ import (
1616 gops "github.com/mitchellh/go-ps"
1717 "github.com/shirou/gopsutil/v3/process"
1818
19- "github.com/golangci/golangci-lint/pkg/config"
2019 "github.com/golangci/golangci-lint/test/testshared"
2120)
2221
@@ -36,7 +35,7 @@ func prepareGithubProject(owner, name string) func(*testing.B) {
3635 _ , err := os .Stat (dir )
3736 if os .IsNotExist (err ) {
3837 repo := fmt .Sprintf ("https://github.com/%s/%s.git" , owner , name )
39- err = exec .Command ("git" , "clone" , repo ).Run ()
38+ err = exec .Command ("git" , "clone" , repo , dir ).Run ()
4039 if err != nil {
4140 b .Fatalf ("can't git clone %s/%s: %s" , owner , name , err )
4241 }
@@ -56,7 +55,6 @@ func getBenchLintersArgsNoMegacheck() []string {
5655 "--enable=errcheck" ,
5756 "--enable=dupl" ,
5857 "--enable=ineffassign" ,
59- "--enable=interfacer" ,
6058 "--enable=unconvert" ,
6159 "--enable=goconst" ,
6260 "--enable=gosec" ,
@@ -69,21 +67,6 @@ func getBenchLintersArgs() []string {
6967 }, getBenchLintersArgsNoMegacheck ()... )
7068}
7169
72- func getGometalinterCommonArgs () []string {
73- return []string {
74- "--deadline=30m" ,
75- "--skip=testdata" ,
76- "--skip=builtin" ,
77- "--vendor" ,
78- "--cyclo-over=30" ,
79- "--dupl-threshold=150" ,
80- "--exclude" , fmt .Sprintf ("(%s)" , strings .Join (config .GetDefaultExcludePatternsStrings (), "|" )),
81- "--disable-all" ,
82- "--enable=vet" ,
83- "--enable=vetshadow" ,
84- }
85- }
86-
8770func printCommand (cmd string , args ... string ) {
8871 if os .Getenv ("PRINT_CMD" ) != "1" {
8972 return
@@ -96,16 +79,6 @@ func printCommand(cmd string, args ...string) {
9679 log .Printf ("%s %s" , cmd , strings .Join (quotedArgs , " " ))
9780}
9881
99- func runGometalinter (b * testing.B ) {
100- args := []string {}
101- args = append (args , getGometalinterCommonArgs ()... )
102- args = append (args , getBenchLintersArgs ()... )
103- args = append (args , "./..." )
104-
105- printCommand ("gometalinter" , args ... )
106- _ = exec .Command ("gometalinter" , args ... ).Run ()
107- }
108-
10982func getGolangciLintCommonArgs () []string {
11083 return []string {"run" , "--no-config" , "--issues-exit-code=0" , "--deadline=30m" , "--disable-all" , "--enable=govet" }
11184}
@@ -211,20 +184,6 @@ type runResult struct {
211184 duration time.Duration
212185}
213186
214- func compare (b * testing.B , gometalinterRun , golangciLintRun func (* testing.B ), repoName , mode string , kLOC int ) {
215- gometalinterRes := runOne (b , gometalinterRun , "gometalinter" )
216- golangciLintRes := runOne (b , golangciLintRun , "golangci-lint" )
217-
218- if mode != "" {
219- mode = " " + mode
220- }
221- log .Printf ("%s (%d kLoC): golangci-lint%s: time: %s, %.1f times faster; memory: %dMB, %.1f times less" ,
222- repoName , kLOC , mode ,
223- golangciLintRes .duration , gometalinterRes .duration .Seconds ()/ golangciLintRes .duration .Seconds (),
224- golangciLintRes .peakMemMB , float64 (gometalinterRes .peakMemMB )/ float64 (golangciLintRes .peakMemMB ),
225- )
226- }
227-
228187func runOne (b * testing.B , run func (* testing.B ), progName string ) * runResult {
229188 doneCh := make (chan struct {})
230189 peakMemCh := trackPeakMemoryUsage (b , doneCh , progName )
@@ -240,7 +199,7 @@ func runOne(b *testing.B, run func(*testing.B), progName string) *runResult {
240199 }
241200}
242201
243- func BenchmarkWithGometalinter (b * testing.B ) {
202+ func BenchmarkGolangciLint (b * testing.B ) {
244203 testshared .NewLintRunner (b ).Install ()
245204
246205 type bcase struct {
@@ -252,10 +211,6 @@ func BenchmarkWithGometalinter(b *testing.B) {
252211 name : "self repo" ,
253212 prepare : prepareGithubProject ("golangci" , "golangci-lint" ),
254213 },
255- {
256- name : "gometalinter repo" ,
257- prepare : prepareGithubProject ("alecthomas" , "gometalinter" ),
258- },
259214 {
260215 name : "hugo" ,
261216 prepare : prepareGithubProject ("gohugoio" , "hugo" ),
@@ -284,7 +239,12 @@ func BenchmarkWithGometalinter(b *testing.B) {
284239 for _ , bc := range bcases {
285240 bc .prepare (b )
286241 lc := getGoLinesTotalCount (b )
242+ result := runOne (b , runGolangciLintForBench , "golangci-lint" )
287243
288- compare (b , runGometalinter , runGolangciLintForBench , bc .name , "" , lc / 1000 )
244+ log .Printf ("%s (%d kLoC): time: %s, memory: %dMB" ,
245+ bc .name , lc / 1000 ,
246+ result .duration ,
247+ result .peakMemMB ,
248+ )
289249 }
290250}
0 commit comments