From ebe1435fbb50bb82bfca53063e8daba4f870ec8d Mon Sep 17 00:00:00 2001 From: zhangyunhao Date: Mon, 18 Apr 2022 15:23:20 +0800 Subject: runtime: add fastrand64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support fastrand64 in the runtime, although fastrand uses wyrand to generate 64-bit random number, it still returns uint32. In some cases, we need to generate a 64-bit random number, the new API would be faster and easier to use, and at least we can use the new function in these places: src/net/dnsclient.go:randInt() src/hash/maphash/maphash.go:MakeSeed() src/runtime/map.go:mapiterinit() name time/op Fastrand-16 0.09ns ± 5% Fastrand64-16 0.09ns ± 6% Change-Id: Ibb97378c7ca59bc7dc15535d4872fa58ea112e6a Reviewed-on: https://go-review.googlesource.com/c/go/+/400734 Reviewed-by: Keith Randall Run-TryBot: Keith Randall Auto-Submit: Keith Randall Reviewed-by: Keith Randall TryBot-Result: Gopher Robot Reviewed-by: Ian Lance Taylor --- src/runtime/export_test.go | 1 + 1 file changed, 1 insertion(+) (limited to 'src/runtime/export_test.go') diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index af27050bfd..8a81f42ca0 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -277,6 +277,7 @@ func CountPagesInUse() (pagesInUse, counted uintptr) { } func Fastrand() uint32 { return fastrand() } +func Fastrand64() uint64 { return fastrand64() } func Fastrandn(n uint32) uint32 { return fastrandn(n) } type ProfBuf profBuf -- cgit v1.3