internal/deephash: simplify API

Reduce to just a single external endpoint.
Convert from a variadic number of interfaces to a slice there.

name    old time/op    new time/op    delta
Hash-8    14.4µs ± 0%    14.0µs ± 1%   -3.08%  (p=0.000 n=9+9)

name    old alloc/op   new alloc/op   delta
Hash-8      873B ± 0%      793B ± 0%   -9.16%  (p=0.000 n=9+6)

name    old allocs/op  new allocs/op  delta
Hash-8      18.0 ± 0%      14.0 ± 0%  -22.22%  (p=0.000 n=10+10)

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
Josh Bleecher Snyder
2021-05-18 13:16:37 -07:00
committed by Josh Bleecher Snyder
parent b371588ce6
commit 988dfcabef
2 changed files with 8 additions and 8 deletions

View File

@ -18,15 +18,15 @@ import (
"tailscale.com/wgengine/wgcfg"
)
func TestDeepPrint(t *testing.T) {
func TestDeepHash(t *testing.T) {
// v contains the types of values we care about for our current callers.
// Mostly we're just testing that we don't panic on handled types.
v := getVal()
hash1 := Hash(v)
hash1 := calcHash(v)
t.Logf("hash: %v", hash1)
for i := 0; i < 20; i++ {
hash2 := Hash(getVal())
hash2 := calcHash(getVal())
if hash1 != hash2 {
t.Error("second hash didn't match")
}
@ -80,7 +80,7 @@ func BenchmarkHash(b *testing.B) {
b.ReportAllocs()
v := getVal()
for i := 0; i < b.N; i++ {
Hash(v)
calcHash(v)
}
}