mirror of https://github.com/portainer/portainer
chore(benchmarks): use b.Loop() BE-12182 (#1072)
parent
89f5a20786
commit
30aba86380
|
@ -189,9 +189,7 @@ func BenchmarkFilterEndpointsBySearchCriteria_PartialMatch(b *testing.B) {
|
||||||
|
|
||||||
searchString := "edge-group"
|
searchString := "edge-group"
|
||||||
|
|
||||||
b.ResetTimer()
|
for b.Loop() {
|
||||||
|
|
||||||
for range b.N {
|
|
||||||
e := filterEndpointsBySearchCriteria(endpoints, endpointGroups, edgeGroups, tagsMap, searchString)
|
e := filterEndpointsBySearchCriteria(endpoints, endpointGroups, edgeGroups, tagsMap, searchString)
|
||||||
if len(e) != n {
|
if len(e) != n {
|
||||||
b.FailNow()
|
b.FailNow()
|
||||||
|
@ -237,13 +235,9 @@ func BenchmarkFilterEndpointsBySearchCriteria_FullMatch(b *testing.B) {
|
||||||
|
|
||||||
searchString := "edge-group"
|
searchString := "edge-group"
|
||||||
|
|
||||||
b.ResetTimer()
|
for b.Loop() {
|
||||||
|
|
||||||
for range b.N {
|
|
||||||
e := filterEndpointsBySearchCriteria(endpoints, endpointGroups, edgeGroups, tagsMap, searchString)
|
e := filterEndpointsBySearchCriteria(endpoints, endpointGroups, edgeGroups, tagsMap, searchString)
|
||||||
if len(e) != n {
|
require.Len(b, e, n)
|
||||||
b.FailNow()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,8 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/portainer/portainer/api/slicesx"
|
"github.com/portainer/portainer/api/slicesx"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Test_Filter(t *testing.T) {
|
func Test_Filter(t *testing.T) {
|
||||||
|
@ -60,12 +62,9 @@ func Benchmark_Filter(b *testing.B) {
|
||||||
source[i] = i
|
source[i] = i
|
||||||
}
|
}
|
||||||
|
|
||||||
b.ResetTimer()
|
for b.Loop() {
|
||||||
for range b.N {
|
|
||||||
e := slicesx.Filter(source, func(x int) bool { return x%2 == 0 })
|
e := slicesx.Filter(source, func(x int) bool { return x%2 == 0 })
|
||||||
if len(e) != n/2 {
|
require.Len(b, e, n/2)
|
||||||
b.FailNow()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,8 +88,6 @@ func Benchmark_FilterInPlace(b *testing.B) {
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := range b.N {
|
for i := range b.N {
|
||||||
e := slicesx.FilterInPlace(copies[i], func(x int) bool { return x%2 == 0 })
|
e := slicesx.FilterInPlace(copies[i], func(x int) bool { return x%2 == 0 })
|
||||||
if len(e) != n/2 {
|
require.Len(b, e, n/2)
|
||||||
b.FailNow()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue