@@ -33,71 +33,102 @@ type runStats struct {
33
33
var benchmarkLog []runStats
34
34
35
35
func BenchmarkDups2Nodes (b * testing.B ) {
36
+ fixedDelay := delay .Fixed (10 * time .Millisecond )
36
37
b .Run ("AllToAll-OneAtATime" , func (b * testing.B ) {
37
- subtestDistributeAndFetch (b , 3 , 100 , allToAll , oneAtATime )
38
+ subtestDistributeAndFetch (b , 3 , 100 , fixedDelay , allToAll , oneAtATime )
38
39
})
39
40
b .Run ("AllToAll-BigBatch" , func (b * testing.B ) {
40
- subtestDistributeAndFetch (b , 3 , 100 , allToAll , batchFetchAll )
41
+ subtestDistributeAndFetch (b , 3 , 100 , fixedDelay , allToAll , batchFetchAll )
41
42
})
42
43
43
44
b .Run ("Overlap1-OneAtATime" , func (b * testing.B ) {
44
- subtestDistributeAndFetch (b , 3 , 100 , overlap1 , oneAtATime )
45
+ subtestDistributeAndFetch (b , 3 , 100 , fixedDelay , overlap1 , oneAtATime )
45
46
})
46
47
47
48
b .Run ("Overlap2-BatchBy10" , func (b * testing.B ) {
48
- subtestDistributeAndFetch (b , 3 , 100 , overlap2 , batchFetchBy10 )
49
+ subtestDistributeAndFetch (b , 3 , 100 , fixedDelay , overlap2 , batchFetchBy10 )
49
50
})
50
51
51
52
b .Run ("Overlap3-OneAtATime" , func (b * testing.B ) {
52
- subtestDistributeAndFetch (b , 3 , 100 , overlap3 , oneAtATime )
53
+ subtestDistributeAndFetch (b , 3 , 100 , fixedDelay , overlap3 , oneAtATime )
53
54
})
54
55
b .Run ("Overlap3-BatchBy10" , func (b * testing.B ) {
55
- subtestDistributeAndFetch (b , 3 , 100 , overlap3 , batchFetchBy10 )
56
+ subtestDistributeAndFetch (b , 3 , 100 , fixedDelay , overlap3 , batchFetchBy10 )
56
57
})
57
58
b .Run ("Overlap3-AllConcurrent" , func (b * testing.B ) {
58
- subtestDistributeAndFetch (b , 3 , 100 , overlap3 , fetchAllConcurrent )
59
+ subtestDistributeAndFetch (b , 3 , 100 , fixedDelay , overlap3 , fetchAllConcurrent )
59
60
})
60
61
b .Run ("Overlap3-BigBatch" , func (b * testing.B ) {
61
- subtestDistributeAndFetch (b , 3 , 100 , overlap3 , batchFetchAll )
62
+ subtestDistributeAndFetch (b , 3 , 100 , fixedDelay , overlap3 , batchFetchAll )
62
63
})
63
64
b .Run ("Overlap3-UnixfsFetch" , func (b * testing.B ) {
64
- subtestDistributeAndFetch (b , 3 , 100 , overlap3 , unixfsFileFetch )
65
+ subtestDistributeAndFetch (b , 3 , 100 , fixedDelay , overlap3 , unixfsFileFetch )
65
66
})
66
67
b .Run ("10Nodes-AllToAll-OneAtATime" , func (b * testing.B ) {
67
- subtestDistributeAndFetch (b , 10 , 100 , allToAll , oneAtATime )
68
+ subtestDistributeAndFetch (b , 10 , 100 , fixedDelay , allToAll , oneAtATime )
68
69
})
69
70
b .Run ("10Nodes-AllToAll-BatchFetchBy10" , func (b * testing.B ) {
70
- subtestDistributeAndFetch (b , 10 , 100 , allToAll , batchFetchBy10 )
71
+ subtestDistributeAndFetch (b , 10 , 100 , fixedDelay , allToAll , batchFetchBy10 )
71
72
})
72
73
b .Run ("10Nodes-AllToAll-BigBatch" , func (b * testing.B ) {
73
- subtestDistributeAndFetch (b , 10 , 100 , allToAll , batchFetchAll )
74
+ subtestDistributeAndFetch (b , 10 , 100 , fixedDelay , allToAll , batchFetchAll )
74
75
})
75
76
b .Run ("10Nodes-AllToAll-AllConcurrent" , func (b * testing.B ) {
76
- subtestDistributeAndFetch (b , 10 , 100 , allToAll , fetchAllConcurrent )
77
+ subtestDistributeAndFetch (b , 10 , 100 , fixedDelay , allToAll , fetchAllConcurrent )
77
78
})
78
79
b .Run ("10Nodes-AllToAll-UnixfsFetch" , func (b * testing.B ) {
79
- subtestDistributeAndFetch (b , 10 , 100 , allToAll , unixfsFileFetch )
80
+ subtestDistributeAndFetch (b , 10 , 100 , fixedDelay , allToAll , unixfsFileFetch )
80
81
})
81
82
b .Run ("10Nodes-OnePeerPerBlock-OneAtATime" , func (b * testing.B ) {
82
- subtestDistributeAndFetch (b , 10 , 100 , onePeerPerBlock , oneAtATime )
83
+ subtestDistributeAndFetch (b , 10 , 100 , fixedDelay , onePeerPerBlock , oneAtATime )
83
84
})
84
85
b .Run ("10Nodes-OnePeerPerBlock-BigBatch" , func (b * testing.B ) {
85
- subtestDistributeAndFetch (b , 10 , 100 , onePeerPerBlock , batchFetchAll )
86
+ subtestDistributeAndFetch (b , 10 , 100 , fixedDelay , onePeerPerBlock , batchFetchAll )
86
87
})
87
88
b .Run ("10Nodes-OnePeerPerBlock-UnixfsFetch" , func (b * testing.B ) {
88
- subtestDistributeAndFetch (b , 10 , 100 , onePeerPerBlock , unixfsFileFetch )
89
+ subtestDistributeAndFetch (b , 10 , 100 , fixedDelay , onePeerPerBlock , unixfsFileFetch )
89
90
})
90
91
b .Run ("200Nodes-AllToAll-BigBatch" , func (b * testing.B ) {
91
- subtestDistributeAndFetch (b , 200 , 20 , allToAll , batchFetchAll )
92
+ subtestDistributeAndFetch (b , 200 , 20 , fixedDelay , allToAll , batchFetchAll )
92
93
})
93
-
94
94
out , _ := json .MarshalIndent (benchmarkLog , "" , " " )
95
95
ioutil .WriteFile ("benchmark.json" , out , 0666 )
96
96
}
97
97
98
- func subtestDistributeAndFetch (b * testing.B , numnodes , numblks int , df distFunc , ff fetchFunc ) {
98
+ const fastSpeed = 60 * time .Millisecond
99
+ const mediumSpeed = 200 * time .Millisecond
100
+ const slowSpeed = 800 * time .Millisecond
101
+ const superSlowSpeed = 4000 * time .Millisecond
102
+ const distribution = 20 * time .Millisecond
103
+
104
+ func BenchmarkDupsManyNodesRealWorldNetwork (b * testing.B ) {
105
+ fastNetworkDelayGenerator := tn .InternetLatencyDelayGenerator (
106
+ mediumSpeed - fastSpeed , slowSpeed - fastSpeed ,
107
+ 0.0 , 0.0 , distribution , nil )
108
+ fastNetworkDelay := delay .Delay (fastSpeed , fastNetworkDelayGenerator )
109
+ averageNetworkDelayGenerator := tn .InternetLatencyDelayGenerator (
110
+ mediumSpeed - fastSpeed , slowSpeed - fastSpeed ,
111
+ 0.3 , 0.3 , distribution , nil )
112
+ averageNetworkDelay := delay .Delay (fastSpeed , averageNetworkDelayGenerator )
113
+ slowNetworkDelayGenerator := tn .InternetLatencyDelayGenerator (
114
+ mediumSpeed - fastSpeed , superSlowSpeed - fastSpeed ,
115
+ 0.3 , 0.3 , distribution , nil )
116
+ slowNetworkDelay := delay .Delay (fastSpeed , slowNetworkDelayGenerator )
117
+
118
+ b .Run ("200Nodes-AllToAll-BigBatch-FastNetwork" , func (b * testing.B ) {
119
+ subtestDistributeAndFetch (b , 300 , 200 , fastNetworkDelay , allToAll , batchFetchAll )
120
+ })
121
+ b .Run ("200Nodes-AllToAll-BigBatch-AverageVariableSpeedNetwork" , func (b * testing.B ) {
122
+ subtestDistributeAndFetch (b , 300 , 200 , averageNetworkDelay , allToAll , batchFetchAll )
123
+ })
124
+ b .Run ("200Nodes-AllToAll-BigBatch-SlowVariableSpeedNetwork" , func (b * testing.B ) {
125
+ subtestDistributeAndFetch (b , 300 , 200 , slowNetworkDelay , allToAll , batchFetchAll )
126
+ })
127
+ }
128
+
129
+ func subtestDistributeAndFetch (b * testing.B , numnodes , numblks int , d delay.D , df distFunc , ff fetchFunc ) {
99
130
start := time .Now ()
100
- net := tn .VirtualNetwork (mockrouting .NewServer (), delay . Fixed ( 10 * time . Millisecond ) )
131
+ net := tn .VirtualNetwork (mockrouting .NewServer (), d )
101
132
sg := NewTestSessionGenerator (net )
102
133
defer sg .Close ()
103
134
0 commit comments