aboutsummaryrefslogtreecommitdiff
path: root/src/bytes/example_test.go
diff options
context:
space:
mode:
authorGiovanni Bajo <rasky@develer.com>2017-09-09 14:59:06 +0200
committerMichael Munday <mike.munday@ibm.com>2017-09-16 10:17:26 +0000
commite7e4a4ffa3330518250c4075e1f16a8ba62414df (patch)
tree606cdb68ede7472f92af54c9d05dfdd6d3af2ac7 /src/bytes/example_test.go
parenta5d6b414493fdbd958dfbc973e6e890c2ee045d1 (diff)
downloadgo-e7e4a4ffa3330518250c4075e1f16a8ba62414df.tar.xz
runtime: improve fastrand with a better generator
The current generator is a simple LSFR, which showed strong correlation in higher bits, as manifested by fastrandn(). Change it with xorshift64+, which is slightly more complex, has a larger state, but has a period of 2^64-1 and is much better at statistical tests. The version used here is capable of passing Diehard and even SmallCrush. Speed is slightly worse but is probably insignificant: name old time/op new time/op delta Fastrand-4 0.77ns ±12% 0.91ns ±21% +17.31% (p=0.048 n=5+5) FastrandHashiter-4 13.6ns ±21% 15.2ns ±17% ~ (p=0.160 n=6+5) Fastrandn/2-4 2.30ns ± 5% 2.45ns ±15% ~ (p=0.222 n=5+5) Fastrandn/3-4 2.36ns ± 7% 2.45ns ± 6% ~ (p=0.222 n=5+5) Fastrandn/4-4 2.33ns ± 8% 2.61ns ±30% ~ (p=0.126 n=6+5) Fastrandn/5-4 2.33ns ± 5% 2.48ns ± 9% ~ (p=0.052 n=6+5) Fixes #21806 Change-Id: I013bb37b463fdfc229a7f324df8fe2da8d286f33 Reviewed-on: https://go-review.googlesource.com/62530 Run-TryBot: Michael Munday <mike.munday@ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/bytes/example_test.go')
0 files changed, 0 insertions, 0 deletions