Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: replace sort.Slice with slices.SortFunc
Since we're already requiring the slices package in stdlib with this refactor, we can utilize this newer function which should be slightly more efficient (and has nicer ergonomics imo). Performs roughly ~11% faster during NewChooser initialization. goos: darwin goarch: arm64 pkg: github.com/mroth/weightedrand/v2 │ v3-dev1.txt │ v3-dev2.txt │ │ sec/op │ sec/op vs base │ NewChooser/size=1e1-8 132.90n ± 0% 70.73n ± 1% -46.78% (p=0.002 n=6) NewChooser/size=1e2-8 472.8n ± 0% 444.1n ± 2% -6.05% (p=0.002 n=6) NewChooser/size=1e3-8 3.412µ ± 0% 3.333µ ± 0% -2.30% (p=0.002 n=6) NewChooser/size=1e4-8 31.03µ ± 0% 30.30µ ± 0% -2.33% (p=0.002 n=6) NewChooser/size=1e5-8 295.9µ ± 0% 291.9µ ± 1% -1.36% (p=0.002 n=6) NewChooser/size=1e6-8 2.843m ± 1% 2.775m ± 1% -2.37% (p=0.002 n=6) NewChooser/size=1e7-8 35.92m ± 1% 32.99m ± 2% -8.16% (p=0.002 n=6) geomean 279.7n 36.41µ -11.60% ¹ ¹ benchmark set differs from baseline; geomeans may not be comparable
- Loading branch information