mirror of
https://github.com/protocolbuffers/protobuf-go.git
synced 2024-12-28 00:19:55 +00:00
492a476312
The use of math/rand in serialization is to provide some form of instability to the output to provide a clear signal to the user that the should not depend on the the property of stability. However, it is reasonable that users expect the output for these to be deterministic. As such, add a detrand package that provides deterministic, yet unstable randomization functionality. Since this package hashes the binary, it does impose a small initialization cost: Benchmark 100000 20712 ns/op 480 B/op 6 allocs/op Change-Id: I232d0fea1789a4278079837a67ee2f63474a4364 Reviewed-on: https://go-review.googlesource.com/c/151340 Reviewed-by: Herbie Ong <herbie@google.com>
15 lines
292 B
Go
15 lines
292 B
Go
// Copyright 2018 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package detrand
|
|
|
|
import "testing"
|
|
|
|
func Benchmark(b *testing.B) {
|
|
b.ReportAllocs()
|
|
for i := 0; i < b.N; i++ {
|
|
binaryHash()
|
|
}
|
|
}
|