aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2025-02-03 15:42:55 +0000
committerGopher Robot <gobot@golang.org>2025-07-30 13:37:28 -0700
commit70a2ff76485477211397ae6399bee06101bc5935 (patch)
tree1840f0b0806e5f9dd92edc91c87dd1b025013b32 /src/internal
parent69338a335ada5882b888fb7eabe0ad6f0e12c986 (diff)
downloadgo-70a2ff76485477211397ae6399bee06101bc5935.tar.xz
runtime: add cgo call benchmark
Change-Id: I12d2ae7dd6a33ecb7110b7d090871e7143fd609f Reviewed-on: https://go-review.googlesource.com/c/go/+/646196 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/runtime/cgobench/bench_test.go26
-rw-r--r--src/internal/runtime/cgobench/funcs.go17
2 files changed, 43 insertions, 0 deletions
diff --git a/src/internal/runtime/cgobench/bench_test.go b/src/internal/runtime/cgobench/bench_test.go
new file mode 100644
index 0000000000..b4d8efec5e
--- /dev/null
+++ b/src/internal/runtime/cgobench/bench_test.go
@@ -0,0 +1,26 @@
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build cgo
+
+package cgobench_test
+
+import (
+ "internal/runtime/cgobench"
+ "testing"
+)
+
+func BenchmarkCgoCall(b *testing.B) {
+ for b.Loop() {
+ cgobench.Empty()
+ }
+}
+
+func BenchmarkCgoCallParallel(b *testing.B) {
+ b.RunParallel(func(pb *testing.PB) {
+ for pb.Next() {
+ cgobench.Empty()
+ }
+ })
+}
diff --git a/src/internal/runtime/cgobench/funcs.go b/src/internal/runtime/cgobench/funcs.go
new file mode 100644
index 0000000000..db685180a1
--- /dev/null
+++ b/src/internal/runtime/cgobench/funcs.go
@@ -0,0 +1,17 @@
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+//go:build cgo
+
+package cgobench
+
+/*
+static void empty() {
+}
+*/
+import "C"
+
+func Empty() {
+ C.empty()
+}