return x+y;
};
+// escape vs noescape
+
+#cgo noescape handleGoStringPointerNoescape
+void handleGoStringPointerNoescape(void *s) {}
+
+void handleGoStringPointerEscape(void *s) {}
+
// Following mimics vulkan complex definitions for benchmarking cgocheck overhead.
typedef uint32_t VkFlags;
C.handleComplexPointer(&a0)
}
})
+ b.Run("string-pointer-escape", func(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ var s string
+ C.handleGoStringPointerEscape(unsafe.Pointer(&s))
+ }
+ })
+ b.Run("string-pointer-noescape", func(b *testing.B) {
+ for i := 0; i < b.N; i++ {
+ var s string
+ C.handleGoStringPointerNoescape(unsafe.Pointer(&s))
+ }
+ })
b.Run("eight-pointers", func(b *testing.B) {
var a0, a1, a2, a3, a4, a5, a6, a7 C.VkDeviceCreateInfo
for i := 0; i < b.N; i++ {