Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
labels: Use slices.Sort instead of sort.Strings
As suggested by package "sort" documentation (https://pkg.go.dev/sort#Strings), slices.Sort should be preferred to sort.Strings since it runs faster. Comparison between sort.Strings ("old") and slices.Sort ("new"): name old time/op new time/op delta pkg:github.com/cilium/cilium/pkg/labels goos:linux goarch:amd64 Labels_SortedList-8 787ns ± 4% 736ns ±12% -6.42% (p=0.014 n=7+8) pkg:github.com/cilium/cilium/pkg/labels/cidr goos:linux goarch:amd64 Labels_SortedListCIDRIDs-8 5.22µs ± 8% 4.67µs ± 4% -10.63% (p=0.000 n=10+10) name old alloc/op new alloc/op delta pkg:github.com/cilium/cilium/pkg/labels goos:linux goarch:amd64 Labels_SortedList-8 360B ± 0% 336B ± 0% -6.67% (p=0.000 n=10+10) pkg:github.com/cilium/cilium/pkg/labels/cidr goos:linux goarch:amd64 Labels_SortedListCIDRIDs-8 1.62kB ± 0% 1.60kB ± 0% -1.48% (p=0.000 n=10+10) name old allocs/op new allocs/op delta pkg:github.com/cilium/cilium/pkg/labels goos:linux goarch:amd64 Labels_SortedList-8 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=10+10) pkg:github.com/cilium/cilium/pkg/labels/cidr goos:linux goarch:amd64 Labels_SortedListCIDRIDs-8 3.00 ± 0% 2.00 ± 0% -33.33% (p=0.000 n=10+10) Signed-off-by: Fabio Falzoi <fabio.falzoi@isovalent.com>
- Loading branch information