MCPcopy
hub / github.com/davyxu/cellnet / client

Function client

benchmark/main.go:44–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42}
43
44func client() {
45
46 queue := cellnet.NewEventQueue()
47
48 p := peer.NewGenericPeer("tcp.Connector", "client", "127.0.0.1:7701", queue)
49
50 rv := proc.NewSyncReceiver(p)
51
52 proc.BindProcessorHandler(p, "tcp.ltv", rv.EventCallback())
53
54 p.Start()
55
56 queue.StartLoop()
57
58 rv.WaitMessage("cellnet.SessionConnected")
59
60 p.(cellnet.TCPConnector).Session().Send(&TestEchoACK{
61 Msg: "hello",
62 Value: 1234,
63 })
64
65 begin := time.Now()
66
67 var lastcheck time.Time
68
69 const total = 10 * time.Second
70
71 for {
72
73 now := time.Now()
74
75 if now.Sub(begin) >= total {
76 break
77 }
78
79 if now.Sub(lastcheck) >= time.Second {
80 fmt.Printf("progress: %d%%\n", now.Sub(begin)*100/total)
81 lastcheck = now
82 }
83
84 rv.Recv(func(ev cellnet.Event) {
85
86 ev.Session().Send(&TestEchoACK{
87 Msg: "hello",
88 Value: 1234,
89 })
90
91 })
92 }
93
94}
95
96var profile = flag.String("profile", "", "write cpu profile to file")
97

Callers 1

mainFunction · 0.70

Calls 11

EventCallbackMethod · 0.95
StartLoopMethod · 0.95
WaitMessageMethod · 0.95
RecvMethod · 0.95
NewEventQueueFunction · 0.92
NewGenericPeerFunction · 0.92
NewSyncReceiverFunction · 0.92
BindProcessorHandlerFunction · 0.92
StartMethod · 0.65
SendMethod · 0.65
SessionMethod · 0.65

Tested by

no test coverage detected