diff --git a/logrus_test.go b/logrus_test.go index 7f1a009..96a66a2 100644 --- a/logrus_test.go +++ b/logrus_test.go @@ -3,9 +3,7 @@ package logrus import ( "bytes" "encoding/json" - "io/ioutil" "testing" - "time" "github.com/stretchr/testify/assert" ) @@ -100,59 +98,3 @@ func TestInfoShouldNotAddSpacesBetweenStrings(t *testing.T) { assert.Equal(t, fields["msg"], "testtest") }) } - -type SlowString string - -func (s SlowString) String() string { - time.Sleep(time.Millisecond) - return string(s) -} - -func getLogAtLevel(l Level) *Logger { - log := New() - log.Level = l - log.Out = ioutil.Discard - return log -} - -func BenchmarkLevelDisplayed(b *testing.B) { - log := getLogAtLevel(Info) - for i := 0; i < b.N; i++ { - log.Info(SlowString("foo")) - } -} - -func BenchmarkLevelHidden(b *testing.B) { - log := getLogAtLevel(Info) - for i := 0; i < b.N; i++ { - log.Debug(SlowString("foo")) - } -} - -func BenchmarkLevelfDisplayed(b *testing.B) { - log := getLogAtLevel(Info) - for i := 0; i < b.N; i++ { - log.Infof("%s", SlowString("foo")) - } -} - -func BenchmarkLevelfHidden(b *testing.B) { - log := getLogAtLevel(Info) - for i := 0; i < b.N; i++ { - log.Debugf("%s", SlowString("foo")) - } -} - -func BenchmarkLevellnDisplayed(b *testing.B) { - log := getLogAtLevel(Info) - for i := 0; i < b.N; i++ { - log.Infoln(SlowString("foo")) - } -} - -func BenchmarkLevellnHidden(b *testing.B) { - log := getLogAtLevel(Info) - for i := 0; i < b.N; i++ { - log.Debugln(SlowString("foo")) - } -}