From d71cd58cbb99b7d184a33d604b5aa209aca10565 Mon Sep 17 00:00:00 2001 From: unclejack Date: Wed, 1 Apr 2015 00:28:50 +0300 Subject: [PATCH] pkg/broadcastwriter: add test w/ "" stream only Signed-off-by: Cristian Staretu --- broadcastwriter/broadcastwriter_test.go | 30 +++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/broadcastwriter/broadcastwriter_test.go b/broadcastwriter/broadcastwriter_test.go index 62ca126..7122782 100644 --- a/broadcastwriter/broadcastwriter_test.go +++ b/broadcastwriter/broadcastwriter_test.go @@ -142,3 +142,33 @@ func BenchmarkBroadcastWriter(b *testing.B) { 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() + } +}