Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show version #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------

Expand All @@ -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
Expand Down Expand Up @@ -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
-------
Expand Down
7 changes: 7 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down