github.com/yinchengtsinghua/golang-Eos-dpos-Ethereum@v0.0.0-20190121132951-92cc4225ed8e/swarm/pot/pot_test.go (about)

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