go-ethereum/log/format_test.go
cui 9b1896bfb5
log: using testing.B.Loop (#32663)
before:
go test -run=^$ -bench=. ./log -timeout=1h 12.19s user 2.19s system 89%
cpu 16.025 total
after:
go test -run=^$ -bench=. ./log -timeout=1h 10.64s user 1.53s system 89%
cpu 13.607 total

---------

Co-authored-by: lightclient <lightclient@protonmail.com>
2025-09-19 17:05:21 -06:00

24 lines
383 B
Go

package log
import (
"math/rand"
"testing"
)
var sink []byte
func BenchmarkPrettyInt64Logfmt(b *testing.B) {
buf := make([]byte, 100)
b.ReportAllocs()
for b.Loop() {
sink = appendInt64(buf, rand.Int63())
}
}
func BenchmarkPrettyUint64Logfmt(b *testing.B) {
buf := make([]byte, 100)
b.ReportAllocs()
for b.Loop() {
sink = appendUint64(buf, rand.Uint64(), false)
}
}