@@ -1068,26 +1068,30 @@ func TestEqualTopologies(t *testing.T) {
10681068}
10691069
10701070func BenchmarkEqualTopologies (b * testing.B ) {
1071- servers := make ([]description.Server , 100 )
1072- for i := 0 ; i < len (servers ); i ++ {
1073- servers [i ] = description.Server {
1074- Addr : address .Address ("127.0.0." + strconv .Itoa (i ) + ":27017" ),
1075- HeartbeatInterval : time .Duration (10 ) * time .Second ,
1076- LastWriteTime : time .Date (2017 , 2 , 11 , 14 , 0 , 0 , 0 , time .UTC ),
1077- LastUpdateTime : time .Date (2017 , 2 , 11 , 14 , 0 , 2 , 0 , time .UTC ),
1078- Kind : description .ServerKindMongos ,
1079- WireVersion : & description.VersionRange {Min : 6 , Max : 21 },
1080- }
1081- }
1082- desc := description.Topology {
1083- Servers : servers ,
1084- }
1071+ for _ , bsize := range []int {10 , 100 , 1000 } {
1072+ b .Run (strconv .Itoa (bsize ), func (b * testing.B ) {
1073+ servers := make ([]description.Server , bsize )
1074+ for i := 0 ; i < len (servers ); i ++ {
1075+ servers [i ] = description.Server {
1076+ Addr : address .Address ("127.0.0." + strconv .Itoa (i ) + ":27017" ),
1077+ HeartbeatInterval : time .Duration (10 ) * time .Second ,
1078+ LastWriteTime : time .Date (2017 , 2 , 11 , 14 , 0 , 0 , 0 , time .UTC ),
1079+ LastUpdateTime : time .Date (2017 , 2 , 11 , 14 , 0 , 2 , 0 , time .UTC ),
1080+ Kind : description .ServerKindMongos ,
1081+ WireVersion : & description.VersionRange {Min : 6 , Max : 21 },
1082+ }
1083+ }
1084+ desc := description.Topology {
1085+ Servers : servers ,
1086+ }
10851087
1086- b .ResetTimer ()
1087- b .RunParallel (func (p * testing.PB ) {
1088- b .ReportAllocs ()
1089- for p .Next () {
1090- _ = equalTopologies (desc , desc )
1091- }
1092- })
1088+ b .ResetTimer ()
1089+ b .RunParallel (func (p * testing.PB ) {
1090+ b .ReportAllocs ()
1091+ for p .Next () {
1092+ _ = equalTopologies (desc , desc )
1093+ }
1094+ })
1095+ })
1096+ }
10931097}
0 commit comments