]> Cypherpunks repositories - gostls13.git/commitdiff
internal/runtime/cgobench: add cgo callback benchmark
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 15 Oct 2025 21:19:13 +0000 (21:19 +0000)
committerGopher Robot <gobot@golang.org>
Mon, 3 Nov 2025 20:46:35 +0000 (12:46 -0800)
Change-Id: I43ea575aff87a3e420477cb26d35185d03df5ccc
Reviewed-on: https://go-review.googlesource.com/c/go/+/713283
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/internal/runtime/cgobench/bench_test.go
src/internal/runtime/cgobench/funcs.go

index b4d8efec5efcf6a256b0293b7202e7e6562da8fe..3b8f9a8ca3aee2273e73b8a1991d6098f4da0f9a 100644 (file)
@@ -24,3 +24,17 @@ func BenchmarkCgoCallParallel(b *testing.B) {
                }
        })
 }
+
+func BenchmarkCgoCallWithCallback(b *testing.B) {
+       for b.Loop() {
+               cgobench.Callback()
+       }
+}
+
+func BenchmarkCgoCallParallelWithCallback(b *testing.B) {
+       b.RunParallel(func(pb *testing.PB) {
+               for pb.Next() {
+                       cgobench.Callback()
+               }
+       })
+}
index db685180a1b594017ef7e1225be07761c7cc6f6f..91efa5127893e526acc08503ed14a26542860d66 100644 (file)
@@ -9,9 +9,24 @@ package cgobench
 /*
 static void empty() {
 }
+
+void go_empty_callback();
+
+static void callback() {
+       go_empty_callback();
+}
+
 */
 import "C"
 
 func Empty() {
        C.empty()
 }
+
+func Callback() {
+       C.callback()
+}
+
+//export go_empty_callback
+func go_empty_callback() {
+}