github.com/aaa256/atlantis@v0.0.0-20210707112435-42ee889287a2/swarm/pot/pot_test.go (about) 1 // Copyright 2017 The go-athereum Authors 2 // This file is part of the go-athereum library. 3 // 4 // The go-athereum library is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU Lesser General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // The go-athereum library is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU Lesser General Public License for more details. 13 // 14 // You should have received a copy of the GNU Lesser General Public License 15 // along with the go-athereum library. If not, see <http://www.gnu.org/licenses/>. 16 package pot 17 18 import ( 19 "errors" 20 "fmt" 21 "math/rand" 22 "runtime" 23 "sync" 24 "testing" 25 "time" 26 27 "github.com/athereum/go-athereum/swarm/log" 28 ) 29 30 const ( 31 maxEachNeighbourTests = 420 32 maxEachNeighbour = 420 33 maxSwap = 420 34 maxSwapTests = 420 35 ) 36 37 // func init() { 38 // log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(false)))) 39 // } 40 41 type testAddr struct { 42 a []byte 43 i int 44 } 45 46 func newTestAddr(s string, i int) *testAddr { 47 return &testAddr{NewAddressFromString(s), i} 48 } 49 50 func (a *testAddr) Address() []byte { 51 return a.a 52 } 53 54 func (a *testAddr) String() string { 55 return Label(a.a) 56 } 57 58 func randomTestAddr(n int, i int) *testAddr { 59 v := RandomAddress().Bin()[:n] 60 return newTestAddr(v, i) 61 } 62 63 func randomtestAddr(n int, i int) *testAddr { 64 v := RandomAddress().Bin()[:n] 65 return newTestAddr(v, i) 66 } 67 68 func indexes(t *Pot) (i []int, po []int) { 69 t.Each(func(v Val, p int) bool { 70 a := v.(*testAddr) 71 i = append(i, a.i) 72 po = append(po, p) 73 return true 74 }) 75 return i, po 76 } 77 78 func testAdd(t *Pot, pof Pof, j int, values ...string) (_ *Pot, n int, f bool) { 79 for i, val := range values { 80 t, n, f = Add(t, newTestAddr(val, i+j), pof) 81 } 82 return t, n, f 83 } 84 85 func TestPotAdd(t *testing.T) { 86 pof := DefaultPof(8) 87 n := NewPot(newTestAddr("00111100", 0), 0) 88 // Pin set correctly 89 exp := "00111100" 90 got := Label(n.Pin())[:8] 91 if got != exp { 92 t.Fatalf("incorrect pinned value. Expected %v, got %v", exp, got) 93 } 94 // check size 95 goti := n.Size() 96 expi := 1 97 if goti != expi { 98 t.Fatalf("incorrect number of elements in Pot. Expected %v, got %v", expi, goti) 99 } 100 101 n, _, _ = testAdd(n, pof, 1, "01111100", "00111100", "01111100", "00011100") 102 // check size 103 goti = n.Size() 104 expi = 3 105 if goti != expi { 106 t.Fatalf("incorrect number of elements in Pot. Expected %v, got %v", expi, goti) 107 } 108 inds, po := indexes(n) 109 got = fmt.Sprintf("%v", inds) 110 exp = "[3 4 2]" 111 if got != exp { 112 t.Fatalf("incorrect indexes in iteration over Pot. Expected %v, got %v", exp, got) 113 } 114 got = fmt.Sprintf("%v", po) 115 exp = "[1 2 0]" 116 if got != exp { 117 t.Fatalf("incorrect po-s in iteration over Pot. Expected %v, got %v", exp, got) 118 } 119 } 120 121 func TestPotRemove(t *testing.T) { 122 pof := DefaultPof(8) 123 n := NewPot(newTestAddr("00111100", 0), 0) 124 n, _, _ = Remove(n, newTestAddr("00111100", 0), pof) 125 exp := "<nil>" 126 got := Label(n.Pin()) 127 if got != exp { 128 t.Fatalf("incorrect pinned value. Expected %v, got %v", exp, got) 129 } 130 n, _, _ = testAdd(n, pof, 1, "00000000", "01111100", "00111100", "00011100") 131 n, _, _ = Remove(n, newTestAddr("00111100", 0), pof) 132 goti := n.Size() 133 expi := 3 134 if goti != expi { 135 t.Fatalf("incorrect number of elements in Pot. Expected %v, got %v", expi, goti) 136 } 137 inds, po := indexes(n) 138 got = fmt.Sprintf("%v", inds) 139 exp = "[2 4 0]" 140 if got != exp { 141 t.Fatalf("incorrect indexes in iteration over Pot. Expected %v, got %v", exp, got) 142 } 143 got = fmt.Sprintf("%v", po) 144 exp = "[1 3 0]" 145 if got != exp { 146 t.Fatalf("incorrect po-s in iteration over Pot. Expected %v, got %v", exp, got) 147 } 148 // remove again 149 n, _, _ = Remove(n, newTestAddr("00111100", 0), pof) 150 inds, _ = indexes(n) 151 got = fmt.Sprintf("%v", inds) 152 exp = "[2 4]" 153 if got != exp { 154 t.Fatalf("incorrect indexes in iteration over Pot. Expected %v, got %v", exp, got) 155 } 156 157 } 158 159 func TestPotSwap(t *testing.T) { 160 for i := 0; i < maxSwapTests; i++ { 161 alen := maxkeylen 162 pof := DefaultPof(alen) 163 max := rand.Intn(maxSwap) 164 165 n := NewPot(nil, 0) 166 var m []*testAddr 167 var found bool 168 for j := 0; j < 2*max; { 169 v := randomtestAddr(alen, j) 170 n, _, found = Add(n, v, pof) 171 if !found { 172 m = append(m, v) 173 j++ 174 } 175 } 176 k := make(map[string]*testAddr) 177 for j := 0; j < max; { 178 v := randomtestAddr(alen, 1) 179 _, found := k[Label(v)] 180 if !found { 181 k[Label(v)] = v 182 j++ 183 } 184 } 185 for _, v := range k { 186 m = append(m, v) 187 } 188 f := func(v Val) Val { 189 tv := v.(*testAddr) 190 if tv.i < max { 191 return nil 192 } 193 tv.i = 0 194 return v 195 } 196 for _, val := range m { 197 n, _, _, _ = Swap(n, val, pof, func(v Val) Val { 198 if v == nil { 199 return val 200 } 201 return f(v) 202 }) 203 } 204 sum := 0 205 n.Each(func(v Val, i int) bool { 206 if v == nil { 207 return true 208 } 209 sum++ 210 tv := v.(*testAddr) 211 if tv.i > 1 { 212 t.Fatalf("item value incorrect, expected 0, got %v", tv.i) 213 } 214 return true 215 }) 216 if sum != 2*max { 217 t.Fatalf("incorrect number of elements. expected %v, got %v", 2*max, sum) 218 } 219 if sum != n.Size() { 220 t.Fatalf("incorrect size. expected %v, got %v", sum, n.Size()) 221 } 222 } 223 } 224 225 func checkPo(val Val, pof Pof) func(Val, int) error { 226 return func(v Val, po int) error { 227 // check the po 228 exp, _ := pof(val, v, 0) 229 if po != exp { 230 return fmt.Errorf("incorrect prox order for item %v in neighbour iteration for %v. Expected %v, got %v", v, val, exp, po) 231 } 232 return nil 233 } 234 } 235 236 func checkOrder(val Val) func(Val, int) error { 237 po := maxkeylen 238 return func(v Val, p int) error { 239 if po < p { 240 return fmt.Errorf("incorrect order for item %v in neighbour iteration for %v. PO %v > %v (previous max)", v, val, p, po) 241 } 242 po = p 243 return nil 244 } 245 } 246 247 func checkValues(m map[string]bool, val Val) func(Val, int) error { 248 return func(v Val, po int) error { 249 duplicate, ok := m[Label(v)] 250 if !ok { 251 return fmt.Errorf("alien value %v", v) 252 } 253 if duplicate { 254 return fmt.Errorf("duplicate value returned: %v", v) 255 } 256 m[Label(v)] = true 257 return nil 258 } 259 } 260 261 var errNoCount = errors.New("not count") 262 263 func testPotEachNeighbour(n *Pot, pof Pof, val Val, expCount int, fs ...func(Val, int) error) error { 264 var err error 265 var count int 266 n.EachNeighbour(val, pof, func(v Val, po int) bool { 267 for _, f := range fs { 268 err = f(v, po) 269 if err != nil { 270 return err.Error() == errNoCount.Error() 271 } 272 } 273 count++ 274 return count != expCount 275 }) 276 if err == nil && count < expCount { 277 return fmt.Errorf("not enough neighbours returned, expected %v, got %v", expCount, count) 278 } 279 return err 280 } 281 282 const ( 283 mergeTestCount = 5 284 mergeTestChoose = 5 285 ) 286 287 func TestPotMergeCommon(t *testing.T) { 288 vs := make([]*testAddr, mergeTestCount) 289 for i := 0; i < maxEachNeighbourTests; i++ { 290 alen := maxkeylen 291 pof := DefaultPof(alen) 292 293 for j := 0; j < len(vs); j++ { 294 vs[j] = randomtestAddr(alen, j) 295 } 296 max0 := rand.Intn(mergeTestChoose) + 1 297 max1 := rand.Intn(mergeTestChoose) + 1 298 n0 := NewPot(nil, 0) 299 n1 := NewPot(nil, 0) 300 log.Trace(fmt.Sprintf("round %v: %v - %v", i, max0, max1)) 301 m := make(map[string]bool) 302 var found bool 303 for j := 0; j < max0; { 304 r := rand.Intn(max0) 305 v := vs[r] 306 n0, _, found = Add(n0, v, pof) 307 if !found { 308 m[Label(v)] = false 309 j++ 310 } 311 } 312 expAdded := 0 313 314 for j := 0; j < max1; { 315 r := rand.Intn(max1) 316 v := vs[r] 317 n1, _, found = Add(n1, v, pof) 318 if !found { 319 j++ 320 } 321 _, found = m[Label(v)] 322 if !found { 323 expAdded++ 324 m[Label(v)] = false 325 } 326 } 327 if i < 6 { 328 continue 329 } 330 expSize := len(m) 331 log.Trace(fmt.Sprintf("%v-0: pin: %v, size: %v", i, n0.Pin(), max0)) 332 log.Trace(fmt.Sprintf("%v-1: pin: %v, size: %v", i, n1.Pin(), max1)) 333 log.Trace(fmt.Sprintf("%v: merged tree size: %v, newly added: %v", i, expSize, expAdded)) 334 n, common := Union(n0, n1, pof) 335 added := n1.Size() - common 336 size := n.Size() 337 338 if expSize != size { 339 t.Fatalf("%v: incorrect number of elements in merged pot, expected %v, got %v\n%v", i, expSize, size, n) 340 } 341 if expAdded != added { 342 t.Fatalf("%v: incorrect number of added elements in merged pot, expected %v, got %v", i, expAdded, added) 343 } 344 if !checkDuplicates(n) { 345 t.Fatalf("%v: merged pot contains duplicates: \n%v", i, n) 346 } 347 for k := range m { 348 _, _, found = Add(n, newTestAddr(k, 0), pof) 349 if !found { 350 t.Fatalf("%v: merged pot (size:%v, added: %v) missing element %v", i, size, added, k) 351 } 352 } 353 } 354 } 355 356 func TestPotMergeScale(t *testing.T) { 357 for i := 0; i < maxEachNeighbourTests; i++ { 358 alen := maxkeylen 359 pof := DefaultPof(alen) 360 max0 := rand.Intn(maxEachNeighbour) + 1 361 max1 := rand.Intn(maxEachNeighbour) + 1 362 n0 := NewPot(nil, 0) 363 n1 := NewPot(nil, 0) 364 log.Trace(fmt.Sprintf("round %v: %v - %v", i, max0, max1)) 365 m := make(map[string]bool) 366 var found bool 367 for j := 0; j < max0; { 368 v := randomtestAddr(alen, j) 369 n0, _, found = Add(n0, v, pof) 370 if !found { 371 m[Label(v)] = false 372 j++ 373 } 374 } 375 expAdded := 0 376 377 for j := 0; j < max1; { 378 v := randomtestAddr(alen, j) 379 n1, _, found = Add(n1, v, pof) 380 if !found { 381 j++ 382 } 383 _, found = m[Label(v)] 384 if !found { 385 expAdded++ 386 m[Label(v)] = false 387 } 388 } 389 if i < 6 { 390 continue 391 } 392 expSize := len(m) 393 log.Trace(fmt.Sprintf("%v-0: pin: %v, size: %v", i, n0.Pin(), max0)) 394 log.Trace(fmt.Sprintf("%v-1: pin: %v, size: %v", i, n1.Pin(), max1)) 395 log.Trace(fmt.Sprintf("%v: merged tree size: %v, newly added: %v", i, expSize, expAdded)) 396 n, common := Union(n0, n1, pof) 397 added := n1.Size() - common 398 size := n.Size() 399 400 if expSize != size { 401 t.Fatalf("%v: incorrect number of elements in merged pot, expected %v, got %v", i, expSize, size) 402 } 403 if expAdded != added { 404 t.Fatalf("%v: incorrect number of added elements in merged pot, expected %v, got %v", i, expAdded, added) 405 } 406 if !checkDuplicates(n) { 407 t.Fatalf("%v: merged pot contains duplicates", i) 408 } 409 for k := range m { 410 _, _, found = Add(n, newTestAddr(k, 0), pof) 411 if !found { 412 t.Fatalf("%v: merged pot (size:%v, added: %v) missing element %v", i, size, added, k) 413 } 414 } 415 } 416 } 417 418 func checkDuplicates(t *Pot) bool { 419 po := -1 420 for _, c := range t.bins { 421 if c == nil { 422 return false 423 } 424 if c.po <= po || !checkDuplicates(c) { 425 return false 426 } 427 po = c.po 428 } 429 return true 430 } 431 432 func TestPotEachNeighbourSync(t *testing.T) { 433 for i := 0; i < maxEachNeighbourTests; i++ { 434 alen := maxkeylen 435 pof := DefaultPof(maxkeylen) 436 max := rand.Intn(maxEachNeighbour/2) + maxEachNeighbour/2 437 pin := randomTestAddr(alen, 0) 438 n := NewPot(pin, 0) 439 m := make(map[string]bool) 440 m[Label(pin)] = false 441 for j := 1; j <= max; j++ { 442 v := randomTestAddr(alen, j) 443 n, _, _ = Add(n, v, pof) 444 m[Label(v)] = false 445 } 446 447 size := n.Size() 448 if size < 2 { 449 continue 450 } 451 count := rand.Intn(size/2) + size/2 452 val := randomTestAddr(alen, max+1) 453 log.Trace(fmt.Sprintf("%v: pin: %v, size: %v, val: %v, count: %v", i, n.Pin(), size, val, count)) 454 err := testPotEachNeighbour(n, pof, val, count, checkPo(val, pof), checkOrder(val), checkValues(m, val)) 455 if err != nil { 456 t.Fatal(err) 457 } 458 minPoFound := alen 459 maxPoNotFound := 0 460 for k, found := range m { 461 po, _ := pof(val, newTestAddr(k, 0), 0) 462 if found { 463 if po < minPoFound { 464 minPoFound = po 465 } 466 } else { 467 if po > maxPoNotFound { 468 maxPoNotFound = po 469 } 470 } 471 } 472 if minPoFound < maxPoNotFound { 473 t.Fatalf("incorrect neighbours returned: found one with PO %v < there was one not found with PO %v", minPoFound, maxPoNotFound) 474 } 475 } 476 } 477 478 func TestPotEachNeighbourAsync(t *testing.T) { 479 for i := 0; i < maxEachNeighbourTests; i++ { 480 max := rand.Intn(maxEachNeighbour/2) + maxEachNeighbour/2 481 alen := maxkeylen 482 pof := DefaultPof(alen) 483 n := NewPot(randomTestAddr(alen, 0), 0) 484 size := 1 485 var found bool 486 for j := 1; j <= max; j++ { 487 v := randomTestAddr(alen, j) 488 n, _, found = Add(n, v, pof) 489 if !found { 490 size++ 491 } 492 } 493 if size != n.Size() { 494 t.Fatal(n) 495 } 496 if size < 2 { 497 continue 498 } 499 count := rand.Intn(size/2) + size/2 500 val := randomTestAddr(alen, max+1) 501 502 mu := sync.Mutex{} 503 m := make(map[string]bool) 504 maxPos := rand.Intn(alen) 505 log.Trace(fmt.Sprintf("%v: pin: %v, size: %v, val: %v, count: %v, maxPos: %v", i, n.Pin(), size, val, count, maxPos)) 506 msize := 0 507 remember := func(v Val, po int) error { 508 if po > maxPos { 509 return errNoCount 510 } 511 m[Label(v)] = true 512 msize++ 513 return nil 514 } 515 if i == 0 { 516 continue 517 } 518 testPotEachNeighbour(n, pof, val, count, remember) 519 d := 0 520 forget := func(v Val, po int) { 521 mu.Lock() 522 defer mu.Unlock() 523 d++ 524 delete(m, Label(v)) 525 } 526 527 n.EachNeighbourAsync(val, pof, count, maxPos, forget, true) 528 if d != msize { 529 t.Fatalf("incorrect number of neighbour calls in async iterator. expected %v, got %v", msize, d) 530 } 531 if len(m) != 0 { 532 t.Fatalf("incorrect neighbour calls in async iterator. %v items missed:\n%v", len(m), n) 533 } 534 } 535 } 536 537 func benchmarkEachNeighbourSync(t *testing.B, max, count int, d time.Duration) { 538 t.ReportAllocs() 539 alen := maxkeylen 540 pof := DefaultPof(alen) 541 pin := randomTestAddr(alen, 0) 542 n := NewPot(pin, 0) 543 var found bool 544 for j := 1; j <= max; { 545 v := randomTestAddr(alen, j) 546 n, _, found = Add(n, v, pof) 547 if !found { 548 j++ 549 } 550 } 551 t.ResetTimer() 552 for i := 0; i < t.N; i++ { 553 val := randomTestAddr(alen, max+1) 554 m := 0 555 n.EachNeighbour(val, pof, func(v Val, po int) bool { 556 time.Sleep(d) 557 m++ 558 return m != count 559 }) 560 } 561 t.StopTimer() 562 stats := new(runtime.MemStats) 563 runtime.ReadMemStats(stats) 564 } 565 566 func benchmarkEachNeighbourAsync(t *testing.B, max, count int, d time.Duration) { 567 t.ReportAllocs() 568 alen := maxkeylen 569 pof := DefaultPof(alen) 570 pin := randomTestAddr(alen, 0) 571 n := NewPot(pin, 0) 572 var found bool 573 for j := 1; j <= max; { 574 v := randomTestAddr(alen, j) 575 n, _, found = Add(n, v, pof) 576 if !found { 577 j++ 578 } 579 } 580 t.ResetTimer() 581 for i := 0; i < t.N; i++ { 582 val := randomTestAddr(alen, max+1) 583 n.EachNeighbourAsync(val, pof, count, alen, func(v Val, po int) { 584 time.Sleep(d) 585 }, true) 586 } 587 t.StopTimer() 588 stats := new(runtime.MemStats) 589 runtime.ReadMemStats(stats) 590 } 591 592 func BenchmarkEachNeighbourSync_3_1_0(t *testing.B) { 593 benchmarkEachNeighbourSync(t, 1000, 10, 1*time.Microsecond) 594 } 595 func BenchmarkEachNeighboursAsync_3_1_0(t *testing.B) { 596 benchmarkEachNeighbourAsync(t, 1000, 10, 1*time.Microsecond) 597 } 598 func BenchmarkEachNeighbourSync_3_2_0(t *testing.B) { 599 benchmarkEachNeighbourSync(t, 1000, 100, 1*time.Microsecond) 600 } 601 func BenchmarkEachNeighboursAsync_3_2_0(t *testing.B) { 602 benchmarkEachNeighbourAsync(t, 1000, 100, 1*time.Microsecond) 603 } 604 func BenchmarkEachNeighbourSync_3_3_0(t *testing.B) { 605 benchmarkEachNeighbourSync(t, 1000, 1000, 1*time.Microsecond) 606 } 607 func BenchmarkEachNeighboursAsync_3_3_0(t *testing.B) { 608 benchmarkEachNeighbourAsync(t, 1000, 1000, 1*time.Microsecond) 609 } 610 611 func BenchmarkEachNeighbourSync_3_1_1(t *testing.B) { 612 benchmarkEachNeighbourSync(t, 1000, 10, 2*time.Microsecond) 613 } 614 func BenchmarkEachNeighboursAsync_3_1_1(t *testing.B) { 615 benchmarkEachNeighbourAsync(t, 1000, 10, 2*time.Microsecond) 616 } 617 func BenchmarkEachNeighbourSync_3_2_1(t *testing.B) { 618 benchmarkEachNeighbourSync(t, 1000, 100, 2*time.Microsecond) 619 } 620 func BenchmarkEachNeighboursAsync_3_2_1(t *testing.B) { 621 benchmarkEachNeighbourAsync(t, 1000, 100, 2*time.Microsecond) 622 } 623 func BenchmarkEachNeighbourSync_3_3_1(t *testing.B) { 624 benchmarkEachNeighbourSync(t, 1000, 1000, 2*time.Microsecond) 625 } 626 func BenchmarkEachNeighboursAsync_3_3_1(t *testing.B) { 627 benchmarkEachNeighbourAsync(t, 1000, 1000, 2*time.Microsecond) 628 } 629 630 func BenchmarkEachNeighbourSync_3_1_2(t *testing.B) { 631 benchmarkEachNeighbourSync(t, 1000, 10, 4*time.Microsecond) 632 } 633 func BenchmarkEachNeighboursAsync_3_1_2(t *testing.B) { 634 benchmarkEachNeighbourAsync(t, 1000, 10, 4*time.Microsecond) 635 } 636 func BenchmarkEachNeighbourSync_3_2_2(t *testing.B) { 637 benchmarkEachNeighbourSync(t, 1000, 100, 4*time.Microsecond) 638 } 639 func BenchmarkEachNeighboursAsync_3_2_2(t *testing.B) { 640 benchmarkEachNeighbourAsync(t, 1000, 100, 4*time.Microsecond) 641 } 642 func BenchmarkEachNeighbourSync_3_3_2(t *testing.B) { 643 benchmarkEachNeighbourSync(t, 1000, 1000, 4*time.Microsecond) 644 } 645 func BenchmarkEachNeighboursAsync_3_3_2(t *testing.B) { 646 benchmarkEachNeighbourAsync(t, 1000, 1000, 4*time.Microsecond) 647 } 648 649 func BenchmarkEachNeighbourSync_3_1_3(t *testing.B) { 650 benchmarkEachNeighbourSync(t, 1000, 10, 8*time.Microsecond) 651 } 652 func BenchmarkEachNeighboursAsync_3_1_3(t *testing.B) { 653 benchmarkEachNeighbourAsync(t, 1000, 10, 8*time.Microsecond) 654 } 655 func BenchmarkEachNeighbourSync_3_2_3(t *testing.B) { 656 benchmarkEachNeighbourSync(t, 1000, 100, 8*time.Microsecond) 657 } 658 func BenchmarkEachNeighboursAsync_3_2_3(t *testing.B) { 659 benchmarkEachNeighbourAsync(t, 1000, 100, 8*time.Microsecond) 660 } 661 func BenchmarkEachNeighbourSync_3_3_3(t *testing.B) { 662 benchmarkEachNeighbourSync(t, 1000, 1000, 8*time.Microsecond) 663 } 664 func BenchmarkEachNeighboursAsync_3_3_3(t *testing.B) { 665 benchmarkEachNeighbourAsync(t, 1000, 1000, 8*time.Microsecond) 666 } 667 668 func BenchmarkEachNeighbourSync_3_1_4(t *testing.B) { 669 benchmarkEachNeighbourSync(t, 1000, 10, 16*time.Microsecond) 670 } 671 func BenchmarkEachNeighboursAsync_3_1_4(t *testing.B) { 672 benchmarkEachNeighbourAsync(t, 1000, 10, 16*time.Microsecond) 673 } 674 func BenchmarkEachNeighbourSync_3_2_4(t *testing.B) { 675 benchmarkEachNeighbourSync(t, 1000, 100, 16*time.Microsecond) 676 } 677 func BenchmarkEachNeighboursAsync_3_2_4(t *testing.B) { 678 benchmarkEachNeighbourAsync(t, 1000, 100, 16*time.Microsecond) 679 } 680 func BenchmarkEachNeighbourSync_3_3_4(t *testing.B) { 681 benchmarkEachNeighbourSync(t, 1000, 1000, 16*time.Microsecond) 682 } 683 func BenchmarkEachNeighboursAsync_3_3_4(t *testing.B) { 684 benchmarkEachNeighbourAsync(t, 1000, 1000, 16*time.Microsecond) 685 }