Add benchmarking for RPC & wire

This commit is contained in:
Jae Kwon
2015-12-08 08:11:29 -08:00
parent 53f74d052f
commit a62c7bfef1
2 changed files with 66 additions and 3 deletions

View File

@ -22,22 +22,25 @@ func main() {
// Read a bunch of responses
go func() {
for {
res, ok := <-ws.ResultsCh
_, ok := <-ws.ResultsCh
if !ok {
break
}
fmt.Println("Received response", res)
//fmt.Println("Received response", string(wire.JSONBytes(res)))
}
}()
// Make a bunch of requests
request := rpctypes.NewRPCRequest("fakeid", "status", nil)
request := rpctypes.NewRPCRequest("fakeid", "net_info", nil)
for i := 0; ; i++ {
reqBytes := wire.JSONBytes(request)
err := ws.WriteMessage(websocket.TextMessage, reqBytes)
if err != nil {
Exit(err.Error())
}
if i%1000 == 0 {
fmt.Println(i)
}
}
ws.Stop()