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