diff --git a/README.md b/README.md index 6120e05..24ff7e4 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,13 @@ go get github.com/parkghost/gohttpbench go build -o gb github.com/parkghost/gohttpbench ``` +or + +``` +git clone github.com/parkghost/gohttpbench +GO111MODULE=off go build -ldflags "-s" -o gb +``` + Usage ----------- @@ -27,6 +34,7 @@ Options are: -T="text/plain": Content-type header for POSTing, eg. 'application/x-www-form-urlencoded' Default is 'text/plain' -c=1: Number of multiple requests to make -h=false: Display usage information (this message) + -V=false: Display version information (and exit) -i=false: Use HEAD instead of GET -k=false: Use HTTP KeepAlive feature -n=1: Number of requests to perform @@ -91,6 +99,11 @@ Options are: 99% 14 100% 32 (longest request) +Version output: +``` +./gb -V +GoHttpBench: 0.2.0-dev; GoLang: go1.21.0 +``` Author ------- diff --git a/config.go b/config.go index ebea58b..35175b0 100644 --- a/config.go +++ b/config.go @@ -60,6 +60,8 @@ func LoadConfig() (config *Config, err error) { showHelp := flag.Bool("h", false, "Display usage information (this message)") + showVersion := flag.Bool("V", false, "Display version information (and exit)") + flag.Usage = func() { fmt.Print("Usage: gb [options] http[s]://hostname[:port]/path\nOptions are:\n") flag.PrintDefaults() @@ -72,6 +74,11 @@ func LoadConfig() (config *Config, err error) { os.Exit(0) } + if *showVersion { + fmt.Print("GoHttpBench: " + GBVersion + "; GoLang: " + runtime.Version() + "\n") + os.Exit(0) + } + if flag.NArg() != 1 { flag.Usage() os.Exit(-1) diff --git a/main.go b/main.go index 69b2a9a..a7deebf 100644 --- a/main.go +++ b/main.go @@ -10,7 +10,7 @@ import ( ) const ( - GBVersion = "0.1.9" + GBVersion = "0.2.0-dev" MaxExecutionTimeout = time.Duration(30) * time.Second MaxRequests = 50000 // for timelimit )