mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
69338a335a
commit
70a2ff7648
3 changed files with 44 additions and 0 deletions
|
|
@ -796,6 +796,7 @@ var depsRules = `
|
||||||
FMT < math/big/internal/asmgen;
|
FMT < math/big/internal/asmgen;
|
||||||
|
|
||||||
FMT, testing < internal/cgrouptest;
|
FMT, testing < internal/cgrouptest;
|
||||||
|
C, CGO < internal/runtime/cgobench;
|
||||||
`
|
`
|
||||||
|
|
||||||
// listStdPkgs returns the same list of packages as "go list std".
|
// listStdPkgs returns the same list of packages as "go list std".
|
||||||
|
|
|
||||||
26
src/internal/runtime/cgobench/bench_test.go
Normal file
26
src/internal/runtime/cgobench/bench_test.go
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
17
src/internal/runtime/cgobench/funcs.go
Normal file
17
src/internal/runtime/cgobench/funcs.go
Normal file
|
|
@ -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()
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue