| // Copyright 2015 The Vanadium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| "v.io/x/ref/runtime/internal/rpc/stream/vif" |
| "v.io/x/ref/test/benchmark" |
| "v.io/x/ref/test/testutil" |
| // benchmarkDialVIF measures VIF creation time over the underlying net connection. |
| func benchmarkDialVIF(b *testing.B, mode options.SecurityLevel) { |
| stats := benchmark.AddStats(b, 16) |
| principal security.Principal |
| blessings security.Blessings |
| if mode == securityDefault { |
| principal = testutil.NewPrincipal("test") |
| blessings = principal.BlessingStore().Default() |
| b.ResetTimer() // Exclude setup time from measurement. |
| for i := 0; i < b.N; i++ { |
| serverch := make(chan *vif.VIF) |
| server, _ := vif.InternalNewAcceptedVIF(ns, naming.FixedRoutingID(0x5), principal, blessings, nil, nil) |
| client, err := vif.InternalNewDialedVIF(nc, naming.FixedRoutingID(0xc), principal, nil, nil) |
| duration := time.Since(start) |
| if server := <-serverch; server != nil { |