commit | 75897c7a292a55304d776f490055a9aef60d4531 | [log] [tgz] |
---|---|---|
author | Panmari <smmuzi@gmail.com> | Wed Jan 11 14:13:18 2023 +0000 |
committer | Gopher Robot <gobot@golang.org> | Wed Jan 11 22:27:15 2023 +0000 |
tree | c57b05bb89df9438d67632735959858fa448ec9b | |
parent | 4b8118a2686a1b7a07c30cba8e484b6beb7e985e [diff] |
slices: inline search into its callers Constructing a lambda and calling the search function has shown to not perform well, being on par with the non-generic sort.Search. Inlining gives a major performance boost ``` ~/exp$ benchstat gotip_master.bench gotip_inlined.bench name old time/op new time/op delta SearchFloats/Size16-4 20.1ns ± 6% 6.2ns ± 1% -69.24% (p=0.000 n=9+9) SearchFloats/Size32-4 22.2ns ± 3% 7.2ns ± 1% -67.69% (p=0.000 n=9+9) SearchFloats/Size64-4 25.8ns ± 6% 8.2ns ± 1% -68.36% (p=0.000 n=9+10) SearchFloats/Size128-4 28.9ns ± 7% 9.2ns ± 0% -68.30% (p=0.000 n=10+10) SearchFloats/Size512-4 34.8ns ± 6% 11.2ns ± 0% -67.83% (p=0.000 n=10+10) SearchFloats/Size1024-4 36.9ns ± 3% 12.2ns ± 0% -66.99% (p=0.000 n=9+9) ``` The story is similar for BinarySearchFunc, even though less severe ``` ~/exp$ benchstat gotip_master_structs.bench gotip_inlined_structs.bench name old time/op new time/op delta BinarySearchFuncStruct/Size16-4 28.9ns ± 2% 19.0ns ± 4% -34.18% (p=0.000 n=9+10) BinarySearchFuncStruct/Size32-4 33.8ns ± 1% 22.0ns ± 5% -35.03% (p=0.000 n=9+10) BinarySearchFuncStruct/Size64-4 39.0ns ± 1% 23.4ns ± 1% -39.98% (p=0.000 n=10+9) BinarySearchFuncStruct/Size128-4 43.8ns ± 1% 26.0ns ± 0% -40.78% (p=0.000 n=9+8) BinarySearchFuncStruct/Size512-4 54.0ns ± 0% 31.5ns ± 1% -41.58% (p=0.000 n=10+10) BinarySearchFuncStruct/Size1024-4 59.0ns ± 0% 34.1ns ± 0% -42.30% (p=0.000 n=9+9) ``` Change-Id: Idf695f6415f7d1f9b69827305bb87061c0fc1e1b GitHub-Last-Rev: 26e17ba6da5ddd6fadfb8264c51cf33b4d0efc3e GitHub-Pull-Request: golang/exp#51 Reviewed-on: https://go-review.googlesource.com/c/exp/+/459037 Run-TryBot: Eli Bendersky <eliben@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Eli Bendersky <eliben@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Nicolas Hillegeer <aktau@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com>
This subrepository holds experimental and deprecated (in the old
directory) packages.
The idea for this subrepository originated as the pkg/exp
directory of the main repository, but its presence there made it unavailable to users of the binary downloads of the Go installation. The subrepository has therefore been created to make it possible to go get
these packages.
Warning: Packages here are experimental and unreliable. Some may one day be promoted to the main repository or other subrepository, or they may be modified arbitrarily or even disappear altogether.
In short, code in this subrepository is not subject to the Go 1 compatibility promise. (No subrepo is, but the promise is even more likely to be violated by go.exp than the others.)
Caveat emptor.