From 500caaeda74dd9c660279036293f4b2997cf0b03 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Sat, 9 Sep 2017 09:42:37 +0200 Subject: Add vendor --- .../gousb/usb/libusb_cgo_benchmark_test.go | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 vendor/github.com/kylelemons/gousb/usb/libusb_cgo_benchmark_test.go (limited to 'vendor/github.com/kylelemons/gousb/usb/libusb_cgo_benchmark_test.go') diff --git a/vendor/github.com/kylelemons/gousb/usb/libusb_cgo_benchmark_test.go b/vendor/github.com/kylelemons/gousb/usb/libusb_cgo_benchmark_test.go new file mode 100644 index 0000000..da8acc9 --- /dev/null +++ b/vendor/github.com/kylelemons/gousb/usb/libusb_cgo_benchmark_test.go @@ -0,0 +1,46 @@ +package usb + +import "testing" + +func BenchmarkCGo(b *testing.B) { + for _, bc := range []struct { + name string + bfunc func(*libusbContext, int) + }{ + { + name: "simple function", + bfunc: func(ctx *libusbContext, N int) { + for i := 0; i < N; i++ { + libusbSetDebug(ctx, i&1) + } + }, + }, + { + name: "method", + bfunc: func(ctx *libusbContext, N int) { + impl := libusbImpl{} + for i := 0; i < N; i++ { + impl.setDebug(ctx, i&1) + } + }, + }, + { + name: "interface", + bfunc: func(ctx *libusbContext, N int) { + var intf libusbIntf = libusbImpl{} + for i := 0; i < N; i++ { + intf.setDebug(ctx, i&1) + } + }, + }, + } { + b.Run(bc.name, func(b *testing.B) { + ctx, err := libusbImpl{}.init() + if err != nil { + b.Fatalf("libusb_init() failed: %v", err) + } + b.ResetTimer() + bc.bfunc(ctx, b.N) + }) + } +} -- cgit v1.2.3