[TextFormatter] Speed up. Fprintf is changed to buffer.Write*
As Fprintf is slower than buffer.WriteString, it's replaced to faster call. Signed-off-by: Anton Tiurin <noxiouz@yandex.ru>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
@@ -45,6 +46,15 @@ var largeFields = Fields{
|
||||
"entries": "yeah",
|
||||
}
|
||||
|
||||
var errorFields = Fields{
|
||||
"foo": fmt.Errorf("bar"),
|
||||
"baz": fmt.Errorf("qux"),
|
||||
}
|
||||
|
||||
func BenchmarkErrorTextFormatter(b *testing.B) {
|
||||
doBenchmark(b, &TextFormatter{DisableColors: true}, errorFields)
|
||||
}
|
||||
|
||||
func BenchmarkSmallTextFormatter(b *testing.B) {
|
||||
doBenchmark(b, &TextFormatter{DisableColors: true}, smallFields)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user