Skip to content

Commit

Permalink
Merge pull request #6 from LK4D4/benchmark_for_8084
Browse files Browse the repository at this point in the history
Benchmark for StdWriter.Write
  • Loading branch information
unclejack committed Sep 17, 2014
2 parents 277aa9c + 55cac6c commit 2f6b1d7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/stdcopy/stdcopy_test.go
@@ -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)
}
}
}

0 comments on commit 2f6b1d7

Please sign in to comment.