diff options
author | Vladimir Lavor <vlavor@cisco.com> | 2018-07-03 10:39:21 +0200 |
---|---|---|
committer | Vladimir Lavor <vlavor@cisco.com> | 2018-07-06 13:18:01 +0200 |
commit | f1bef4a3c66f4408afdeb64cda62ccd8562d0fc6 (patch) | |
tree | 5767c18051f97362a00b1a4dfe90ec9480247032 /examples/cmd/perf-bench | |
parent | 5276b9439d0f902e125a5113bfa4f1b6622aea18 (diff) |
make api.Channel as interface
Change-Id: I052d241ab09043b1195beebeee99df4d8536621f
Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
Diffstat (limited to 'examples/cmd/perf-bench')
-rw-r--r-- | examples/cmd/perf-bench/perf-bench.go | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/examples/cmd/perf-bench/perf-bench.go b/examples/cmd/perf-bench/perf-bench.go index f3ff752..b1f4dcf 100644 --- a/examples/cmd/perf-bench/perf-bench.go +++ b/examples/cmd/perf-bench/perf-bench.go @@ -95,7 +95,7 @@ func main() { fmt.Printf("Requests per second: %.0f\n", float64(cnt)/elapsed.Seconds()) } -func syncTest(ch *api.Channel, cnt int) { +func syncTest(ch api.Channel, cnt int) { fmt.Printf("Running synchronous perf test with %d requests...\n", cnt) for i := 0; i < cnt; i++ { @@ -110,7 +110,7 @@ func syncTest(ch *api.Channel, cnt int) { } } -func asyncTest(ch *api.Channel, cnt int) { +func asyncTest(ch api.Channel, cnt int) { fmt.Printf("Running asynchronous perf test with %d requests...\n", cnt) // start a new go routine that reads the replies @@ -125,20 +125,20 @@ func asyncTest(ch *api.Channel, cnt int) { wg.Wait() } -func sendAsyncRequests(ch *api.Channel, cnt int) { +func sendAsyncRequests(ch api.Channel, cnt int) { for i := 0; i < cnt; i++ { - ch.ReqChan <- &api.VppRequest{ + ch.GetRequestChannel() <- &api.VppRequest{ Message: &vpe.ControlPing{}, } } } -func readAsyncReplies(ch *api.Channel, expectedCnt int, wg *sync.WaitGroup) { +func readAsyncReplies(ch api.Channel, expectedCnt int, wg *sync.WaitGroup) { cnt := 0 for { // receive a reply - reply := <-ch.ReplyChan + reply := <-ch.GetReplyChannel() if reply.Error != nil { log.Println("Error in reply:", reply.Error) os.Exit(1) @@ -146,7 +146,7 @@ func readAsyncReplies(ch *api.Channel, expectedCnt int, wg *sync.WaitGroup) { // decode the message msg := &vpe.ControlPingReply{} - err := ch.MsgDecoder.DecodeMsg(reply.Data, msg) + err := ch.GetMessageDecoder().DecodeMsg(reply.Data, msg) if reply.Error != nil { log.Println("Error by decoding:", err) os.Exit(1) @@ -159,4 +159,4 @@ func readAsyncReplies(ch *api.Channel, expectedCnt int, wg *sync.WaitGroup) { return } } -}
\ No newline at end of file +} |