pkg/broadcastwriter: add test w/ "" stream only
Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com>
This commit is contained in:
parent
266eb178e1
commit
d71cd58cbb
1 changed files with 30 additions and 0 deletions
|
@ -142,3 +142,33 @@ func BenchmarkBroadcastWriter(b *testing.B) {
|
||||||
b.StartTimer()
|
b.StartTimer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkBroadcastWriterWithoutStdoutStderr(b *testing.B) {
|
||||||
|
writer := New()
|
||||||
|
setUpWriter := func() {
|
||||||
|
for i := 0; i < 100; i++ {
|
||||||
|
writer.AddWriter(devNullCloser(0), "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
testLine := "Line that thinks that it is log line from docker"
|
||||||
|
var buf bytes.Buffer
|
||||||
|
for i := 0; i < 100; i++ {
|
||||||
|
buf.Write([]byte(testLine + "\n"))
|
||||||
|
}
|
||||||
|
// line without eol
|
||||||
|
buf.Write([]byte(testLine))
|
||||||
|
testText := buf.Bytes()
|
||||||
|
b.SetBytes(int64(5 * len(testText)))
|
||||||
|
b.ResetTimer()
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
setUpWriter()
|
||||||
|
|
||||||
|
for j := 0; j < 5; j++ {
|
||||||
|
if _, err := writer.Write(testText); err != nil {
|
||||||
|
b.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
writer.Clean()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue