github.com/ydb-platform/ydb-go-sdk/v3@v3.57.0/internal/xstring/buffer_test.go (about)

     1  package xstring
     2  
     3  import (
     4  	"bytes"
     5  	"testing"
     6  )
     7  
     8  func BenchmarkBufferWithPool(b *testing.B) {
     9  	b.ReportAllocs()
    10  	for i := 0; i < b.N; i++ {
    11  		func() {
    12  			buffer := Buffer()
    13  			buffer.WriteString(b.Name())
    14  			defer buffer.Free()
    15  		}()
    16  	}
    17  }
    18  
    19  func BenchmarkBufferWithoutPool(b *testing.B) {
    20  	b.ReportAllocs()
    21  	for i := 0; i < b.N; i++ {
    22  		func() {
    23  			buffer := bytes.Buffer{}
    24  			buffer.WriteString(b.Name())
    25  		}()
    26  	}
    27  }