mirror of
https://github.com/tailscale/tailscale.git
synced 2024-11-29 04:55:31 +00:00
util/deephash: add a benchmark and some benchmark data
No code changes. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
9ae3bd0939
commit
58f2ef6085
@ -75,6 +75,56 @@ func getVal() []interface{} {
|
||||
{2: 3}: true,
|
||||
{3: 4}: false,
|
||||
},
|
||||
&tailcfg.MapResponse{
|
||||
DERPMap: &tailcfg.DERPMap{
|
||||
Regions: map[int]*tailcfg.DERPRegion{
|
||||
1: &tailcfg.DERPRegion{
|
||||
RegionID: 1,
|
||||
RegionCode: "foo",
|
||||
Nodes: []*tailcfg.DERPNode{
|
||||
{
|
||||
Name: "n1",
|
||||
RegionID: 1,
|
||||
HostName: "foo.com",
|
||||
},
|
||||
{
|
||||
Name: "n2",
|
||||
RegionID: 1,
|
||||
HostName: "bar.com",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
DNSConfig: &tailcfg.DNSConfig{
|
||||
Resolvers: []tailcfg.DNSResolver{
|
||||
{Addr: "10.0.0.1"},
|
||||
},
|
||||
},
|
||||
PacketFilter: []tailcfg.FilterRule{
|
||||
{
|
||||
SrcIPs: []string{"1.2.3.4"},
|
||||
DstPorts: []tailcfg.NetPortRange{
|
||||
{
|
||||
IP: "1.2.3.4/32",
|
||||
Ports: tailcfg.PortRange{1, 2},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Peers: []*tailcfg.Node{
|
||||
{
|
||||
ID: 1,
|
||||
},
|
||||
{
|
||||
ID: 2,
|
||||
},
|
||||
},
|
||||
UserProfiles: []tailcfg.UserProfile{
|
||||
{ID: 1, LoginName: "foo@bar.com"},
|
||||
{ID: 2, LoginName: "bar@foo.com"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -139,6 +189,15 @@ func BenchmarkHashMapAcyclic(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkTailcfgNode(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
|
||||
node := new(tailcfg.Node)
|
||||
for i := 0; i < b.N; i++ {
|
||||
sink = Hash(node)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExhaustive(t *testing.T) {
|
||||
seen := make(map[[sha256.Size]byte]bool)
|
||||
for i := 0; i < 100000; i++ {
|
||||
|
Loading…
Reference in New Issue
Block a user