@@ -10,6 +10,7 @@ import (
1010 "os"
1111 "os/exec"
1212 "path/filepath"
13+ "slices"
1314 "strconv"
1415 "strings"
1516 "time"
@@ -310,8 +311,9 @@ func checkForRegressions(cfg config, csvOutput string) error {
310311 benchName := record [nameIdx ]
311312
312313 // Check time/op regression
313- if contains (cfg .failMetrics , "time/op" ) && oldTimeIdx != - 1 && newTimeIdx != - 1 {
314- if regression := checkMetricRegression (record , oldTimeIdx , newTimeIdx , cfg .threshold ); regression != "" {
314+ if slices .Contains (cfg .failMetrics , "time/op" ) && oldTimeIdx != - 1 && newTimeIdx != - 1 {
315+ regression := checkMetricRegression (record , oldTimeIdx , newTimeIdx , cfg .threshold )
316+ if regression != "" {
315317 regressions = append (
316318 regressions ,
317319 fmt .Sprintf ("%s: time/op %s" , benchName , regression ),
@@ -320,15 +322,17 @@ func checkForRegressions(cfg config, csvOutput string) error {
320322 }
321323
322324 // Check B/op regression
323- if contains (cfg .failMetrics , "B/op" ) && oldBytesIdx != - 1 && newBytesIdx != - 1 {
324- if regression := checkMetricRegression (record , oldBytesIdx , newBytesIdx , cfg .threshold ); regression != "" {
325+ if slices .Contains (cfg .failMetrics , "B/op" ) && oldBytesIdx != - 1 && newBytesIdx != - 1 {
326+ regression := checkMetricRegression (record , oldBytesIdx , newBytesIdx , cfg .threshold )
327+ if regression != "" {
325328 regressions = append (regressions , fmt .Sprintf ("%s: B/op %s" , benchName , regression ))
326329 }
327330 }
328331
329332 // Check allocs/op regression
330- if contains (cfg .failMetrics , "allocs/op" ) && oldAllocsIdx != - 1 && newAllocsIdx != - 1 {
331- if regression := checkMetricRegression (record , oldAllocsIdx , newAllocsIdx , cfg .threshold ); regression != "" {
333+ if slices .Contains (cfg .failMetrics , "allocs/op" ) && oldAllocsIdx != - 1 && newAllocsIdx != - 1 {
334+ regression := checkMetricRegression (record , oldAllocsIdx , newAllocsIdx , cfg .threshold )
335+ if regression != "" {
332336 regressions = append (
333337 regressions ,
334338 fmt .Sprintf ("%s: allocs/op %s" , benchName , regression ),
@@ -405,13 +409,3 @@ func parseMetricValue(s string) (float64, error) {
405409
406410 return strconv .ParseFloat (s , 64 )
407411}
408-
409- func contains (slice []string , item string ) bool {
410- for _ , s := range slice {
411- if s == item {
412- return true
413- }
414- }
415-
416- return false
417- }
0 commit comments