MCPcopy Create free account
hub / github.com/33cn/chain33 / BenchmarkSendMessage

Function BenchmarkSendMessage

queue/queue_test.go:299–331  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

297}
298
299func BenchmarkSendMessage(b *testing.B) {
300 q := New("channel")
301 //mempool
302 b.ReportAllocs()
303 go func() {
304 client := q.Client()
305 client.Sub("mempool")
306 defer client.Close()
307 for msg := range client.Recv() {
308 go func(msg *Message) {
309 if msg.Ty == types.EventTx {
310 msg.Reply(client.NewMessage("mempool", types.EventReply, types.Reply{IsOk: true, Msg: []byte("word")}))
311 }
312 }(msg)
313 }
314 }()
315 go q.Start()
316 client := q.Client()
317 //high 优先级
318 msg := client.NewMessage("mempool", types.EventTx, "hello")
319 for i := 0; i < b.N; i++ {
320 err := client.Send(msg, true)
321 if err != nil {
322 b.Error(err)
323 return
324 }
325 _, err = client.Wait(msg)
326 if err != nil {
327 b.Error(err)
328 return
329 }
330 }
331}
332
333func BenchmarkStructChan(b *testing.B) {
334 ch := make(chan struct{})

Callers

nothing calls this directly

Calls 11

ReplyMethod · 0.95
NewFunction · 0.70
ClientMethod · 0.65
SubMethod · 0.65
CloseMethod · 0.65
RecvMethod · 0.65
NewMessageMethod · 0.65
StartMethod · 0.65
SendMethod · 0.65
ErrorMethod · 0.65
WaitMethod · 0.65

Tested by

no test coverage detected