Skip to content

sasanrose/gbench

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GBench

Build Status Coverage Status Go Report Card GoDoc

HTTP Load Testing And Benchmarking Tool inspired by Apache Benchmark and Siege.

Requirements

You need Golang installed and ready on your system.

Installation

go install github.com/sasanrose/gbench

Usage:

Gbench has three main subcommands: exec, json and render. Exec is used, as the name suggests, to execute a benchmark based on a single url. While json subcommands runs benchmark based on a JSON configruation file and allows you to run benchmarks for different paths for a single host concurrently. This has the benefit of reproducing the same benchmark just by sharing the JSON file. Both exec and json subcommands store the result of benchmark in a JSON file (report.json in the current directy by default). And at last but not least, the render subcommand can convert the generated report to a more human readable format.

$ gbench -h
Usage:                                                                                                                                                                                       
  gbench [flags]
  gbench [command]

Available Commands:
  exec        Executes the benchmark                                                                                                                                                         
  help        Help about any command                                                                                                                                                         
  json        Executes the benchmark using json configuration                                                                                                                                
  render      Render the report generated by exec command                                                                                                                                    

Flags:
  -h, --help   help for gbench

Use "gbench [command] --help" for more information about a command.
$ gbench exec -h
Usage:                                                                                                                                                                                       
  gbench exec [flags]                                                                                                                                                                        

Flags:
  -c, --concurrency int             Number of concurrent requests. (default 1)
      --connect-timeout duration    Connection timeout (0 means no timeout).
  -b, --cookie string               A string to be sent as raw cookie (In the format of Set-Cookie HTTP header).
  -d, --data strings                Sends the specified data in a request. The format should be 'key=val' or 'key1=val1&key2=val2'. This can be used multiple times.
  -F, --force                       Force overwrite for the report file.
  -H, --header strings              HTTP header in format of 'key: value' or 'key: value;' or 'key;'. This can be used multiple times.
  -h, --help                        help for exec
  -o, --output string               The path to store the report of benchmark. (default "./report.json")
      --proxy string                HTTP proxy.
  -X, --request string              Specify a custom HTTP method. (default "GET")
      --response-timeout duration   Response timeout (0 means no timeout).
  -s, --status-codes ints           Define what should be considered as a successful status code. (default [200,202,201])
  -r, --total-requests int          Number of total requests to send. (default 1)
  -u, --user string                 Specify the user name and password to use for server authentication in the format of user:password. Currently only supports Basic Auth.
                                    The user name and passwords are split up on the first colon, as a result it is impossible to use a colon in the user name.
$ gbench json -h
Usage:                                                                                                                                                                                       
  gbench json [flags]                                                                                                                                                                        

Flags:
  -F, --force           Force overwrite for the report file.
  -h, --help            help for json
  -o, --output string   The path to store the report of benchmark. (default "./report.json")
$ gbench render -h
Sample usage:                                                                                                                                                                                
gbench render (Will use all the default values)
gbench render -i ./path/to/report.json
gbench render -i ./path/to/report.json --driver html
gbench render -i ./path/to/report.json --driver html -a 0.0.0.0 -p 7777

Usage:
  gbench render [flags]

Flags:
  -a, --address string   Address to access the html report. (default "localhost")
  -d, --driver string    Driver to use for rendering the report. Accepted values are 'cli'and 'html'. (default "cli")
  -h, --help             help for render
  -i, --input string     Path to the report file. (default "./report.json")
  -p, --port string      Port to access the html report. (default "8080")

The following is a sample JSON config file that can be used with json subcommand. Most of the keys are based on flags of exec subcommand. The only required keys are host and paths.

{                                                                                                                                                                                            
    "host": "http://localhost:8080",
    "concurrency": 5,
    "requests": 100,
    "status-codes": [200, 201],
    "user": "user:pass",
    "proxy": "http://proxy:3333",
    "connect-timeout": 1000000000,
    "response-timeout": 5000000000,
    "headers": ["X-Custome-Header: TestValue;"],
    "cookie": "some-raw-cookie",
    "paths": [
        {
            "path": "/"
        },
        {
            "path": "/test",
            "method": "post",
            "user": "user:pass",
            "headers": ["X-Custome-Header: TestValue;"],
            "cookie": "some-raw-cookie",
            "data": ["key1=val1&key2=val2", "key3=val3"]
        }
    ]
}

Disclaimer: Gbench is still beta version. The API may change in future.

About

HTTP Load Testing And Benchmarking Tool

Resources

License

Stars

Watchers

Forks

Packages

No packages published