github.com/geph-official/geph2@v0.22.6-0.20210211030601-f527cb59b0df/libs/fastudp/bench_test.go (about) 1 package fastudp 2 3 import ( 4 "net" 5 "testing" 6 ) 7 8 func BenchmarkStockUDP(b *testing.B) { 9 pc, err := net.ListenPacket("udp", ":") 10 if err != nil { 11 panic(err) 12 } 13 defer pc.Close() 14 tgtAddr, _ := net.ResolveUDPAddr("udp", "1.1.1.1:11111") 15 batchPC := NewConn(pc.(*net.UDPConn)) 16 zz := []byte("HELLO") 17 for i := 0; i < b.N; i++ { 18 _, err = batchPC.WriteTo(zz, tgtAddr) 19 if err != nil { 20 panic(err) 21 } 22 } 23 }