mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
log: improve benchmark
This commit is contained in:
parent
0c8b6ca8c7
commit
4b6d32dbfa
1 changed files with 14 additions and 5 deletions
|
|
@ -57,11 +57,21 @@ func BenchmarkTraceLogging(b *testing.B) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func BenchmarkGloggerTerminal(b *testing.B) {
|
func BenchmarkTerminalHandler(b *testing.B) {
|
||||||
glogHandler := NewGlogHandler(NewTerminalHandler(io.Discard, false))
|
l := NewLogger(NewTerminalHandler(io.Discard, false))
|
||||||
glogHandler.Verbosity(LevelInfo)
|
benchmarkLogger(b, l)
|
||||||
l := NewLogger(glogHandler)
|
}
|
||||||
|
func BenchmarkLogfmtHandler(b *testing.B) {
|
||||||
|
l := NewLogger(LogfmtHandler(io.Discard))
|
||||||
|
benchmarkLogger(b, l)
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkJSONHandler(b *testing.B) {
|
||||||
|
l := NewLogger(JSONHandler(io.Discard))
|
||||||
|
benchmarkLogger(b, l)
|
||||||
|
}
|
||||||
|
|
||||||
|
func benchmarkLogger(b *testing.B, l Logger) {
|
||||||
type custom struct {
|
type custom struct {
|
||||||
A string
|
A string
|
||||||
B int8
|
B int8
|
||||||
|
|
@ -73,7 +83,6 @@ func BenchmarkGloggerTerminal(b *testing.B) {
|
||||||
nilbig *big.Int
|
nilbig *big.Int
|
||||||
err = fmt.Errorf("Oh nooes it's crap")
|
err = fmt.Errorf("Oh nooes it's crap")
|
||||||
)
|
)
|
||||||
|
|
||||||
b.ReportAllocs()
|
b.ReportAllocs()
|
||||||
b.ResetTimer()
|
b.ResetTimer()
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue