runtime/trace: add Log benchmark

This is a pretty decent benchmark of the baseline event cost.

Change-Id: I22a7fa3411bd80be3bd8093d5933e29062cb1377
Reviewed-on: https://go-review.googlesource.com/c/go/+/723060
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
Michael Anthony Knyszek
2025-11-19 03:37:09 +00:00
committed by Michael Knyszek
parent 6aeacdff38
commit 8d9906cd34

View File

@@ -6,6 +6,7 @@ package trace_test
import (
"context"
"io"
. "runtime/trace"
"testing"
)
@@ -34,3 +35,15 @@ func BenchmarkNewTask(b *testing.B) {
}
})
}
func BenchmarkLog(b *testing.B) {
b.ReportAllocs()
Start(io.Discard)
defer Stop()
ctx := context.Background()
for b.Loop() {
Log(ctx, "", "")
}
}