github.com/enetx/g@v1.0.80/tests/map_benchmark_test.go (about)

     1  package g_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/enetx/g"
     7  )
     8  
     9  // go test -bench=. -benchmem -count=4
    10  
    11  func genM() g.Map[g.String, int] {
    12  	mo := g.NewMap[g.String, int](10000)
    13  	for i := range 10000 {
    14  		mo.Set(g.NewInt(i).ToString(), i)
    15  	}
    16  
    17  	return mo
    18  }
    19  
    20  func BenchmarkMEq(b *testing.B) {
    21  	m := genM()
    22  	m2 := m.Clone()
    23  
    24  	b.ResetTimer()
    25  
    26  	for n := 0; n < b.N; n++ {
    27  		_ = m.Eq(m2)
    28  	}
    29  }