(b *testing.B, data []byte, conf testutil.LatencyConfig)
| 35 | } |
| 36 | |
| 37 | func benchCat(b *testing.B, data []byte, conf testutil.LatencyConfig) error { |
| 38 | b.StopTimer() |
| 39 | ctx, cancel := context.WithCancel(context.Background()) |
| 40 | defer cancel() |
| 41 | |
| 42 | // create network |
| 43 | mn := mocknet.New() |
| 44 | mn.SetLinkDefaults(mocknet.LinkOptions{ |
| 45 | Latency: conf.NetworkLatency, |
| 46 | // TODO add to conf. This is tricky because we want 0 values to be functional. |
| 47 | Bandwidth: math.MaxInt32, |
| 48 | }) |
| 49 | |
| 50 | adder, err := core.NewNode(ctx, &core.BuildCfg{ |
| 51 | Online: true, |
| 52 | Host: mock.MockHostOption(mn), |
| 53 | }) |
| 54 | if err != nil { |
| 55 | return err |
| 56 | } |
| 57 | defer adder.Close() |
| 58 | |
| 59 | catter, err := core.NewNode(ctx, &core.BuildCfg{ |
| 60 | Online: true, |
| 61 | Host: mock.MockHostOption(mn), |
| 62 | }) |
| 63 | if err != nil { |
| 64 | return err |
| 65 | } |
| 66 | defer catter.Close() |
| 67 | |
| 68 | adderAPI, err := coreapi.NewCoreAPI(adder) |
| 69 | if err != nil { |
| 70 | return err |
| 71 | } |
| 72 | |
| 73 | catterAPI, err := coreapi.NewCoreAPI(catter) |
| 74 | if err != nil { |
| 75 | return err |
| 76 | } |
| 77 | |
| 78 | err = mn.LinkAll() |
| 79 | if err != nil { |
| 80 | return err |
| 81 | } |
| 82 | |
| 83 | bs1 := []peer.AddrInfo{adder.Peerstore.PeerInfo(adder.Identity)} |
| 84 | bs2 := []peer.AddrInfo{catter.Peerstore.PeerInfo(catter.Identity)} |
| 85 | |
| 86 | if err := catter.Bootstrap(bootstrap.BootstrapConfigWithPeers(bs1)); err != nil { |
| 87 | return err |
| 88 | } |
| 89 | if err := adder.Bootstrap(bootstrap.BootstrapConfigWithPeers(bs2)); err != nil { |
| 90 | return err |
| 91 | } |
| 92 | |
| 93 | added, err := adderAPI.Unixfs().Add(ctx, files.NewBytesFile(data)) |
| 94 | if err != nil { |
no test coverage detected