File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -132,3 +132,46 @@ func BenchmarkUnixSend(b *testing.B) {
132
132
<- ch
133
133
}
134
134
}
135
+
136
+ func BenchmarkUDPSendExactMatch (b * testing.B ) {
137
+ laddr , err := net .ResolveUDPAddr ("udp" , "127.0.0.1:0" )
138
+ if err != nil {
139
+ b .Fatal (err )
140
+ }
141
+ srv , err := osc .ListenUDP ("udp" , laddr )
142
+ if err != nil {
143
+ b .Fatal (err )
144
+ }
145
+ raddr , err := net .ResolveUDPAddr ("udp" , srv .LocalAddr ().String ())
146
+ if err != nil {
147
+ b .Fatal (err )
148
+ }
149
+ conn , err := osc .DialUDP ("udp" , nil , raddr )
150
+ if err != nil {
151
+ b .Fatal (err )
152
+ }
153
+ var (
154
+ ch = make (chan struct {})
155
+ val = struct {}{}
156
+ )
157
+ go srv .Serve (1 , osc.Dispatcher {
158
+ "/ping" : osc .Method (func (m osc.Message ) error {
159
+ if _ , err := m .Arguments [0 ].ReadInt32 (); err != nil {
160
+ return err
161
+ }
162
+ ch <- val
163
+ return nil
164
+ }),
165
+ })
166
+ msg := osc.Message {Address : "/ping" , Arguments : osc.Arguments {osc .Int (0 )}}
167
+
168
+ srv .SetExactMatch (true )
169
+
170
+ b .ResetTimer ()
171
+
172
+ for i := 0 ; i < b .N ; i ++ {
173
+ msg .Arguments [0 ] = osc .Int (i )
174
+ conn .Send (msg )
175
+ <- ch
176
+ }
177
+ }
You can’t perform that action at this time.
0 commit comments