master
go 83 lines 5.07 KB
Raw
1 package integrationtest
2
3 import (
4 "testing"
5
6 "github.com/ipfs/kubo/thirdparty/unit"
7 testutil "github.com/libp2p/go-libp2p-testing/net"
8 )
9
10 func benchmarkAddCat(numBytes int64, conf testutil.LatencyConfig, b *testing.B) {
11 b.StopTimer()
12 b.SetBytes(numBytes)
13 data := RandomBytes(numBytes) // we don't want to measure the time it takes to generate this data
14 b.StartTimer()
15
16 for n := 0; n < b.N; n++ {
17 if err := DirectAddCat(data, conf); err != nil {
18 b.Fatal(err)
19 }
20 }
21 }
22
23 var instant = testutil.LatencyConfig{}.AllInstantaneous()
24
25 func BenchmarkInstantaneousAddCat1KB(b *testing.B) { benchmarkAddCat(1*unit.KB, instant, b) }
26 func BenchmarkInstantaneousAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, instant, b) }
27 func BenchmarkInstantaneousAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, instant, b) }
28 func BenchmarkInstantaneousAddCat4MB(b *testing.B) { benchmarkAddCat(4*unit.MB, instant, b) }
29 func BenchmarkInstantaneousAddCat8MB(b *testing.B) { benchmarkAddCat(8*unit.MB, instant, b) }
30 func BenchmarkInstantaneousAddCat16MB(b *testing.B) { benchmarkAddCat(16*unit.MB, instant, b) }
31 func BenchmarkInstantaneousAddCat32MB(b *testing.B) { benchmarkAddCat(32*unit.MB, instant, b) }
32 func BenchmarkInstantaneousAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.MB, instant, b) }
33 func BenchmarkInstantaneousAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, instant, b) }
34 func BenchmarkInstantaneousAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, instant, b) }
35
36 var routing = testutil.LatencyConfig{}.RoutingSlow()
37
38 func BenchmarkRoutingSlowAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, routing, b) }
39 func BenchmarkRoutingSlowAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, routing, b) }
40 func BenchmarkRoutingSlowAddCat4MB(b *testing.B) { benchmarkAddCat(4*unit.MB, routing, b) }
41 func BenchmarkRoutingSlowAddCat8MB(b *testing.B) { benchmarkAddCat(8*unit.MB, routing, b) }
42 func BenchmarkRoutingSlowAddCat16MB(b *testing.B) { benchmarkAddCat(16*unit.MB, routing, b) }
43 func BenchmarkRoutingSlowAddCat32MB(b *testing.B) { benchmarkAddCat(32*unit.MB, routing, b) }
44 func BenchmarkRoutingSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.MB, routing, b) }
45 func BenchmarkRoutingSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, routing, b) }
46 func BenchmarkRoutingSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, routing, b) }
47 func BenchmarkRoutingSlowAddCat512MB(b *testing.B) { benchmarkAddCat(512*unit.MB, routing, b) }
48
49 var network = testutil.LatencyConfig{}.NetworkNYtoSF()
50
51 func BenchmarkNetworkSlowAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, network, b) }
52 func BenchmarkNetworkSlowAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, network, b) }
53 func BenchmarkNetworkSlowAddCat4MB(b *testing.B) { benchmarkAddCat(4*unit.MB, network, b) }
54 func BenchmarkNetworkSlowAddCat8MB(b *testing.B) { benchmarkAddCat(8*unit.MB, network, b) }
55 func BenchmarkNetworkSlowAddCat16MB(b *testing.B) { benchmarkAddCat(16*unit.MB, network, b) }
56 func BenchmarkNetworkSlowAddCat32MB(b *testing.B) { benchmarkAddCat(32*unit.MB, network, b) }
57 func BenchmarkNetworkSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.MB, network, b) }
58 func BenchmarkNetworkSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, network, b) }
59 func BenchmarkNetworkSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, network, b) }
60
61 var hdd = testutil.LatencyConfig{}.Blockstore7200RPM()
62
63 func BenchmarkBlockstoreSlowAddCat1MB(b *testing.B) { benchmarkAddCat(1*unit.MB, hdd, b) }
64 func BenchmarkBlockstoreSlowAddCat2MB(b *testing.B) { benchmarkAddCat(2*unit.MB, hdd, b) }
65 func BenchmarkBlockstoreSlowAddCat4MB(b *testing.B) { benchmarkAddCat(4*unit.MB, hdd, b) }
66 func BenchmarkBlockstoreSlowAddCat8MB(b *testing.B) { benchmarkAddCat(8*unit.MB, hdd, b) }
67 func BenchmarkBlockstoreSlowAddCat16MB(b *testing.B) { benchmarkAddCat(16*unit.MB, hdd, b) }
68 func BenchmarkBlockstoreSlowAddCat32MB(b *testing.B) { benchmarkAddCat(32*unit.MB, hdd, b) }
69 func BenchmarkBlockstoreSlowAddCat64MB(b *testing.B) { benchmarkAddCat(64*unit.MB, hdd, b) }
70 func BenchmarkBlockstoreSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, hdd, b) }
71 func BenchmarkBlockstoreSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, hdd, b) }
72
73 var mixed = testutil.LatencyConfig{}.NetworkNYtoSF().BlockstoreSlowSSD2014().RoutingSlow()
74
75 func BenchmarkMixedAddCat1MBXX(b *testing.B) { benchmarkAddCat(1*unit.MB, mixed, b) }
76 func BenchmarkMixedAddCat2MBXX(b *testing.B) { benchmarkAddCat(2*unit.MB, mixed, b) }
77 func BenchmarkMixedAddCat4MBXX(b *testing.B) { benchmarkAddCat(4*unit.MB, mixed, b) }
78 func BenchmarkMixedAddCat8MBXX(b *testing.B) { benchmarkAddCat(8*unit.MB, mixed, b) }
79 func BenchmarkMixedAddCat16MBX(b *testing.B) { benchmarkAddCat(16*unit.MB, mixed, b) }
80 func BenchmarkMixedAddCat32MBX(b *testing.B) { benchmarkAddCat(32*unit.MB, mixed, b) }
81 func BenchmarkMixedAddCat64MBX(b *testing.B) { benchmarkAddCat(64*unit.MB, mixed, b) }
82 func BenchmarkMixedAddCat128MB(b *testing.B) { benchmarkAddCat(128*unit.MB, mixed, b) }
83 func BenchmarkMixedAddCat256MB(b *testing.B) { benchmarkAddCat(256*unit.MB, mixed, b) }