@@ -16,7 +16,6 @@ import (
16
16
gops "github.com/mitchellh/go-ps"
17
17
"github.com/shirou/gopsutil/v3/process"
18
18
19
- "github.com/golangci/golangci-lint/pkg/config"
20
19
"github.com/golangci/golangci-lint/test/testshared"
21
20
)
22
21
@@ -36,7 +35,7 @@ func prepareGithubProject(owner, name string) func(*testing.B) {
36
35
_ , err := os .Stat (dir )
37
36
if os .IsNotExist (err ) {
38
37
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 ()
40
39
if err != nil {
41
40
b .Fatalf ("can't git clone %s/%s: %s" , owner , name , err )
42
41
}
@@ -56,7 +55,6 @@ func getBenchLintersArgsNoMegacheck() []string {
56
55
"--enable=errcheck" ,
57
56
"--enable=dupl" ,
58
57
"--enable=ineffassign" ,
59
- "--enable=interfacer" ,
60
58
"--enable=unconvert" ,
61
59
"--enable=goconst" ,
62
60
"--enable=gosec" ,
@@ -69,21 +67,6 @@ func getBenchLintersArgs() []string {
69
67
}, getBenchLintersArgsNoMegacheck ()... )
70
68
}
71
69
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
-
87
70
func printCommand (cmd string , args ... string ) {
88
71
if os .Getenv ("PRINT_CMD" ) != "1" {
89
72
return
@@ -96,16 +79,6 @@ func printCommand(cmd string, args ...string) {
96
79
log .Printf ("%s %s" , cmd , strings .Join (quotedArgs , " " ))
97
80
}
98
81
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
-
109
82
func getGolangciLintCommonArgs () []string {
110
83
return []string {"run" , "--no-config" , "--issues-exit-code=0" , "--deadline=30m" , "--disable-all" , "--enable=govet" }
111
84
}
@@ -211,20 +184,6 @@ type runResult struct {
211
184
duration time.Duration
212
185
}
213
186
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
-
228
187
func runOne (b * testing.B , run func (* testing.B ), progName string ) * runResult {
229
188
doneCh := make (chan struct {})
230
189
peakMemCh := trackPeakMemoryUsage (b , doneCh , progName )
@@ -240,7 +199,7 @@ func runOne(b *testing.B, run func(*testing.B), progName string) *runResult {
240
199
}
241
200
}
242
201
243
- func BenchmarkWithGometalinter (b * testing.B ) {
202
+ func BenchmarkGolangciLint (b * testing.B ) {
244
203
testshared .NewLintRunner (b ).Install ()
245
204
246
205
type bcase struct {
@@ -252,10 +211,6 @@ func BenchmarkWithGometalinter(b *testing.B) {
252
211
name : "self repo" ,
253
212
prepare : prepareGithubProject ("golangci" , "golangci-lint" ),
254
213
},
255
- {
256
- name : "gometalinter repo" ,
257
- prepare : prepareGithubProject ("alecthomas" , "gometalinter" ),
258
- },
259
214
{
260
215
name : "hugo" ,
261
216
prepare : prepareGithubProject ("gohugoio" , "hugo" ),
@@ -284,7 +239,12 @@ func BenchmarkWithGometalinter(b *testing.B) {
284
239
for _ , bc := range bcases {
285
240
bc .prepare (b )
286
241
lc := getGoLinesTotalCount (b )
242
+ result := runOne (b , runGolangciLintForBench , "golangci-lint" )
287
243
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
+ )
289
249
}
290
250
}
0 commit comments