github.com/linapex/ethereum-go-chinese@v0.0.0-20190316121929-f8b7a73c3fa1/swarm/pot/pot_test.go (about)

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