mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
internal/runtime/cgobench: add cgo callback benchmark
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>
This commit is contained in:
parent
5f8fdb720c
commit
17b57078ab
2 changed files with 29 additions and 0 deletions
|
|
@ -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()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue