github.com/wlan0/docker@v1.5.0/pkg/stdcopy/stdcopy_test.go (about)

     1  package stdcopy
     2  
     3  import (
     4  	"bytes"
     5  	"io/ioutil"
     6  	"testing"
     7  )
     8  
     9  func BenchmarkWrite(b *testing.B) {
    10  	w := NewStdWriter(ioutil.Discard, Stdout)
    11  	data := []byte("Test line for testing stdwriter performance\n")
    12  	data = bytes.Repeat(data, 100)
    13  	b.SetBytes(int64(len(data)))
    14  	b.ResetTimer()
    15  	for i := 0; i < b.N; i++ {
    16  		if _, err := w.Write(data); err != nil {
    17  			b.Fatal(err)
    18  		}
    19  	}
    20  }