github.com/omrikiei/mem_test@v0.0.0-20220809075836-de951e8d121f/mem_test.go (about)

     1  package mem
     2  
     3  import "testing"
     4  
     5  const times = 100000
     6  
     7  func BenchamarkByRef(b *testing.B) {
     8  	s := foo{a: "somevalue"}
     9  	concat := ""
    10  	for i := 0; i < times; i++ {
    11  		concat += printer(&s)
    12  	}
    13  }
    14  
    15  func BenchmarkByVal(b *testing.B) {
    16  	s := foo{a: "somevalue"}
    17  	concat := ""
    18  	for i := 0; i < times; i++ {
    19  		concat += printer(s)
    20  	}
    21  }