]> Cypherpunks repositories - gostls13.git/commitdiff
runtime/trace: add Log benchmark
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 19 Nov 2025 03:37:09 +0000 (03:37 +0000)
committerMichael Knyszek <mknyszek@google.com>
Fri, 21 Nov 2025 22:03:19 +0000 (14:03 -0800)
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>

src/runtime/trace/annotation_test.go

index 3bd767bfbe5e7ec751c7eca4f0125d3caebdf2d1..ea108432309fd3111efa7980a678eef80607ff4b 100644 (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, "", "")
+       }
+}