github.com/moontrade/unsafe@v0.9.1/cgo/call_test.go (about) 1 package cgo 2 3 import ( 4 "runtime" 5 "testing" 6 "time" 7 ) 8 9 func BenchmarkCall(b *testing.B) { 10 b.Run("Assembly Trampoline Call", func(b *testing.B) { 11 for i := 0; i < b.N; i++ { 12 NonBlockingNoop() 13 } 14 }) 15 b.Run("CGO Trampoline Call", func(b *testing.B) { 16 for i := 0; i < b.N; i++ { 17 BlockingNoop() 18 } 19 }) 20 b.Run("CGO Standard", func(b *testing.B) { 21 for i := 0; i < b.N; i++ { 22 CGONoop() 23 } 24 }) 25 } 26 27 func TestSleep(t *testing.T) { 28 runtime.LockOSThread() 29 defer runtime.UnlockOSThread() 30 for i := 0; i < 10000; i++ { 31 NonBlockingSleep(time.Second) 32 println(time.Now().UnixNano()) 33 } 34 }