bench_test.go 4.81 KB
Newer Older
1 2
package epictest

3 4
import (
	"testing"
5

6 7 8 9
	testutil "github.com/jbenet/go-ipfs/util/testutil"
)

func benchmarkAddCat(numBytes int64, conf testutil.LatencyConfig, b *testing.B) {
10 11 12 13 14 15

	b.StopTimer()
	b.SetBytes(numBytes)
	data := RandomBytes(numBytes) // we don't want to measure the time it takes to generate this data
	b.StartTimer()

16
	for n := 0; n < b.N; n++ {
Brian Tiger Chow's avatar
rename  
Brian Tiger Chow committed
17
		if err := DirectAddCat(data, conf); err != nil {
18 19 20 21 22
			b.Fatal(err)
		}
	}
}

23
var instant = testutil.LatencyConfig{}.All_Instantaneous()
24

Brian Tiger Chow's avatar
Brian Tiger Chow committed
25
func BenchmarkInstantaneousAddCat1KB(b *testing.B)   { benchmarkAddCat(1*KB, instant, b) }
26 27 28 29 30 31 32 33 34
func BenchmarkInstantaneousAddCat1MB(b *testing.B)   { benchmarkAddCat(1*MB, instant, b) }
func BenchmarkInstantaneousAddCat2MB(b *testing.B)   { benchmarkAddCat(2*MB, instant, b) }
func BenchmarkInstantaneousAddCat4MB(b *testing.B)   { benchmarkAddCat(4*MB, instant, b) }
func BenchmarkInstantaneousAddCat8MB(b *testing.B)   { benchmarkAddCat(8*MB, instant, b) }
func BenchmarkInstantaneousAddCat16MB(b *testing.B)  { benchmarkAddCat(16*MB, instant, b) }
func BenchmarkInstantaneousAddCat32MB(b *testing.B)  { benchmarkAddCat(32*MB, instant, b) }
func BenchmarkInstantaneousAddCat64MB(b *testing.B)  { benchmarkAddCat(64*MB, instant, b) }
func BenchmarkInstantaneousAddCat128MB(b *testing.B) { benchmarkAddCat(128*MB, instant, b) }
func BenchmarkInstantaneousAddCat256MB(b *testing.B) { benchmarkAddCat(256*MB, instant, b) }
35

36
var routing = testutil.LatencyConfig{}.Routing_Slow()
37

Brian Tiger Chow's avatar
Brian Tiger Chow committed
38 39 40 41 42 43 44 45 46 47
func BenchmarkRoutingSlowAddCat1MB(b *testing.B)   { benchmarkAddCat(1*MB, routing, b) }
func BenchmarkRoutingSlowAddCat2MB(b *testing.B)   { benchmarkAddCat(2*MB, routing, b) }
func BenchmarkRoutingSlowAddCat4MB(b *testing.B)   { benchmarkAddCat(4*MB, routing, b) }
func BenchmarkRoutingSlowAddCat8MB(b *testing.B)   { benchmarkAddCat(8*MB, routing, b) }
func BenchmarkRoutingSlowAddCat16MB(b *testing.B)  { benchmarkAddCat(16*MB, routing, b) }
func BenchmarkRoutingSlowAddCat32MB(b *testing.B)  { benchmarkAddCat(32*MB, routing, b) }
func BenchmarkRoutingSlowAddCat64MB(b *testing.B)  { benchmarkAddCat(64*MB, routing, b) }
func BenchmarkRoutingSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*MB, routing, b) }
func BenchmarkRoutingSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*MB, routing, b) }
func BenchmarkRoutingSlowAddCat512MB(b *testing.B) { benchmarkAddCat(512*MB, routing, b) }
48

49
var network = testutil.LatencyConfig{}.Network_NYtoSF()
50

51 52 53 54 55 56 57 58 59
func BenchmarkNetworkSlowAddCat1MB(b *testing.B)   { benchmarkAddCat(1*MB, network, b) }
func BenchmarkNetworkSlowAddCat2MB(b *testing.B)   { benchmarkAddCat(2*MB, network, b) }
func BenchmarkNetworkSlowAddCat4MB(b *testing.B)   { benchmarkAddCat(4*MB, network, b) }
func BenchmarkNetworkSlowAddCat8MB(b *testing.B)   { benchmarkAddCat(8*MB, network, b) }
func BenchmarkNetworkSlowAddCat16MB(b *testing.B)  { benchmarkAddCat(16*MB, network, b) }
func BenchmarkNetworkSlowAddCat32MB(b *testing.B)  { benchmarkAddCat(32*MB, network, b) }
func BenchmarkNetworkSlowAddCat64MB(b *testing.B)  { benchmarkAddCat(64*MB, network, b) }
func BenchmarkNetworkSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*MB, network, b) }
func BenchmarkNetworkSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*MB, network, b) }
60

61
var hdd = testutil.LatencyConfig{}.Blockstore_7200RPM()
62

Brian Tiger Chow's avatar
Brian Tiger Chow committed
63 64 65 66 67 68 69 70 71
func BenchmarkBlockstoreSlowAddCat1MB(b *testing.B)   { benchmarkAddCat(1*MB, hdd, b) }
func BenchmarkBlockstoreSlowAddCat2MB(b *testing.B)   { benchmarkAddCat(2*MB, hdd, b) }
func BenchmarkBlockstoreSlowAddCat4MB(b *testing.B)   { benchmarkAddCat(4*MB, hdd, b) }
func BenchmarkBlockstoreSlowAddCat8MB(b *testing.B)   { benchmarkAddCat(8*MB, hdd, b) }
func BenchmarkBlockstoreSlowAddCat16MB(b *testing.B)  { benchmarkAddCat(16*MB, hdd, b) }
func BenchmarkBlockstoreSlowAddCat32MB(b *testing.B)  { benchmarkAddCat(32*MB, hdd, b) }
func BenchmarkBlockstoreSlowAddCat64MB(b *testing.B)  { benchmarkAddCat(64*MB, hdd, b) }
func BenchmarkBlockstoreSlowAddCat128MB(b *testing.B) { benchmarkAddCat(128*MB, hdd, b) }
func BenchmarkBlockstoreSlowAddCat256MB(b *testing.B) { benchmarkAddCat(256*MB, hdd, b) }
Brian Tiger Chow's avatar
Brian Tiger Chow committed
72

73
var mixed = testutil.LatencyConfig{}.Network_NYtoSF().Blockstore_SlowSSD2014().Routing_Slow()
Brian Tiger Chow's avatar
Brian Tiger Chow committed
74

Brian Tiger Chow's avatar
Brian Tiger Chow committed
75 76 77 78 79 80 81
func BenchmarkMixedAddCat1MBXX(b *testing.B) { benchmarkAddCat(1*MB, mixed, b) }
func BenchmarkMixedAddCat2MBXX(b *testing.B) { benchmarkAddCat(2*MB, mixed, b) }
func BenchmarkMixedAddCat4MBXX(b *testing.B) { benchmarkAddCat(4*MB, mixed, b) }
func BenchmarkMixedAddCat8MBXX(b *testing.B) { benchmarkAddCat(8*MB, mixed, b) }
func BenchmarkMixedAddCat16MBX(b *testing.B) { benchmarkAddCat(16*MB, mixed, b) }
func BenchmarkMixedAddCat32MBX(b *testing.B) { benchmarkAddCat(32*MB, mixed, b) }
func BenchmarkMixedAddCat64MBX(b *testing.B) { benchmarkAddCat(64*MB, mixed, b) }
Brian Tiger Chow's avatar
Brian Tiger Chow committed
82 83
func BenchmarkMixedAddCat128MB(b *testing.B) { benchmarkAddCat(128*MB, mixed, b) }
func BenchmarkMixedAddCat256MB(b *testing.B) { benchmarkAddCat(256*MB, mixed, b) }