aboutsummaryrefslogtreecommitdiffstats
path: root/examples/perf-bench/perf-bench.go
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2020-06-16 10:40:34 +0200
committerOndrej Fabry <ofabry@cisco.com>2020-06-16 10:40:34 +0200
commit280b1c6c83b676ef4e592f4ecf60cb5b54b6a753 (patch)
treebf9a35f020de061ba66a432411ee44866405fe76 /examples/perf-bench/perf-bench.go
parentf049390060630c0085fe4ad683c83a4a14a47ffb (diff)
Optimize socketclient adapter and add various code improvements
This commit includes: Features - optimized [socketclient](adapter/socketclient) adapter and add method to set client name - added list of compatible messages to `CompatibilityError` Fixes - `MsgCodec` will recover panic occurring during a message decoding - calling `Unsubscibe` will close the notification channel Other - improved log messages to provide more relevant info Examples - added more code samples of working with unions in [union example](examples/union-example) - added profiling mode to [perf bench](examples/perf-bench) example - improved [simple client](examples/simple-client) example to work properly even with multiple runs Dependencies - updated `github.com/sirupsen/logrus` dep to `v1.6.0` - updated `github.com/lunixbochs/struc` dep to `v0.0.0-20200521075829-a4cb8d33dbbe` Change-Id: I136a3968ccf9e93760d7ee2b9902fc7e6390a09d Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'examples/perf-bench/perf-bench.go')
-rw-r--r--examples/perf-bench/perf-bench.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/examples/perf-bench/perf-bench.go b/examples/perf-bench/perf-bench.go
index f48c154..81d183c 100644
--- a/examples/perf-bench/perf-bench.go
+++ b/examples/perf-bench/perf-bench.go
@@ -20,6 +20,7 @@ import (
"flag"
"fmt"
"log"
+ "os"
"time"
"github.com/pkg/profile"
@@ -39,14 +40,14 @@ const (
func main() {
// parse optional flags
- var sync, prof bool
+ var sync bool
var cnt int
- var sock string
+ var sock, prof string
flag.BoolVar(&sync, "sync", false, "run synchronous perf test")
- flag.StringVar(&sock, "socket", socketclient.DefaultSocketName, "Path to VPP API socket")
- flag.String("socket", statsclient.DefaultSocketName, "Path to VPP stats socket")
+ flag.StringVar(&sock, "api-socket", socketclient.DefaultSocketName, "Path to VPP API socket")
+ flag.String("stats-socket", statsclient.DefaultSocketName, "Path to VPP stats socket")
flag.IntVar(&cnt, "count", 0, "count of requests to be sent to VPP")
- flag.BoolVar(&prof, "prof", false, "generate profile data")
+ flag.StringVar(&prof, "prof", "", "enable profiling mode [mem, cpu]")
flag.Parse()
if cnt == 0 {
@@ -58,8 +59,16 @@ func main() {
}
}
- if prof {
- defer profile.Start().Stop()
+ switch prof {
+ case "mem":
+ defer profile.Start(profile.MemProfile, profile.MemProfileRate(1)).Stop()
+ case "cpu":
+ defer profile.Start(profile.CPUProfile).Stop()
+ case "":
+ default:
+ fmt.Printf("invalid profiling mode: %q\n", prof)
+ flag.Usage()
+ os.Exit(1)
}
a := socketclient.NewVppClient(sock)