diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2019-03-08 11:18:22 +0100 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2019-03-08 11:18:22 +0100 |
commit | 6dd658f579ae4e1d9704e14380b69fe906c57ad2 (patch) | |
tree | c915b74c7fb53a6f811e9a1d39aab8dfc60daabd /examples/perf-bench | |
parent | 45e38494c1d65ad9178ad15f4048c0ab16f98b77 (diff) |
Add socketclient implementation
Change-Id: Ibf9edc0e5911d08229ac590b37c5afbc27f424a0
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'examples/perf-bench')
-rw-r--r-- | examples/perf-bench/perf-bench.go | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/examples/perf-bench/perf-bench.go b/examples/perf-bench/perf-bench.go index 24d3ebb..e5b0926 100644 --- a/examples/perf-bench/perf-bench.go +++ b/examples/perf-bench/perf-bench.go @@ -25,7 +25,9 @@ import ( "github.com/pkg/profile" "github.com/sirupsen/logrus" - "git.fd.io/govpp.git" + "git.fd.io/govpp.git/adapter" + "git.fd.io/govpp.git/adapter/socketclient" + "git.fd.io/govpp.git/adapter/vppapiclient" "git.fd.io/govpp.git/api" "git.fd.io/govpp.git/core" "git.fd.io/govpp.git/examples/bin_api/vpe" @@ -38,9 +40,10 @@ const ( func main() { // parse optional flags - var sync, prof bool + var sync, prof, sock bool var cnt int flag.BoolVar(&sync, "sync", false, "run synchronous perf test") + flag.BoolVar(&sock, "sock", false, "use socket client for VPP API") flag.IntVar(&cnt, "count", 0, "count of requests to be sent to VPP") flag.BoolVar(&prof, "prof", false, "generate profile data") flag.Parse() @@ -58,8 +61,15 @@ func main() { defer profile.Start().Stop() } + var a adapter.VppAPI + if sock { + a = socketclient.NewVppClient("/run/vpp-api.sock") + } else { + a = vppapiclient.NewVppClient("") + } + // connect to VPP - conn, err := govpp.Connect("") + conn, err := core.Connect(a) if err != nil { log.Fatalln("Error:", err) } @@ -72,6 +82,8 @@ func main() { } defer ch.Close() + ch.SetReplyTimeout(time.Second * 2) + // log only errors core.SetLogger(&logrus.Logger{Level: logrus.ErrorLevel}) @@ -89,6 +101,8 @@ func main() { elapsed := time.Since(start) fmt.Println("Test took:", elapsed) fmt.Printf("Requests per second: %.0f\n", float64(cnt)/elapsed.Seconds()) + + time.Sleep(time.Second) } func syncTest(ch api.Channel, cnt int) { |