mirror of
https://github.com/gonum/gonum.git
synced 2025-12-24 13:47:56 +08:00
Using slices.BinarySearch instead of sort.Search increases the speed of
findSegment by a factor of two and overall performance by about 30%.
goos: linux
goarch: amd64
pkg: gonum.org/v1/gonum/interp
cpu: AMD Ryzen 7 5800 8-Core Processor
│ old.bench │ new.bench │
│ sec/op │ sec/op vs base │
FindSegment-16 104.60n ± 1% 50.78n ± 1% -51.45% (p=0.000 n=10)
NewPiecewiseLinear-16 114.5n ± 5% 112.2n ± 2% ~ (p=0.109 n=10)
PiecewiseLinearPredict-16 116.00n ± 1% 84.44n ± 2% -27.21% (p=0.000 n=10)
PiecewiseConstantPredict-16 87.95n ± 2% 63.93n ± 1% -27.31% (p=0.000 n=10)
geomean 105.2n 74.47n -29.18%