Benchmark for StdWriter.Write
Signed-off-by: Alexandr Morozov <lk4d4@docker.com>
This commit is contained in:
parent
3a38c974cb
commit
4f58459de9
1 changed files with 20 additions and 0 deletions
20
stdcopy/stdcopy_test.go
Normal file
20
stdcopy/stdcopy_test.go
Normal file
|
@ -0,0 +1,20 @@
|
|||
package stdcopy
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func BenchmarkWrite(b *testing.B) {
|
||||
w := NewStdWriter(ioutil.Discard, Stdout)
|
||||
data := []byte("Test line for testing stdwriter performance\n")
|
||||
data = bytes.Repeat(data, 100)
|
||||
b.SetBytes(int64(len(data)))
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
if _, err := w.Write(data); err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue