httpbench

package module
v0.0.0-...-371c995 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 14 Imported by: 0

README

httpbench build-release-binary Go Report Card

Description

HttpBench is a simple utility for bench marking HTTP servers.

Dependencies
  • to build yourself, you must have Go v1.13+ installed
Installing

Download the latest release here

Executing program
gopher@localhost→ httpbench
httpbench

Usage:
  httpbench --url https://mywebsite.com
  httpbench --url https://mywebsite.com --count 100

Options:
  -b, --bodyFile string   body file in json
  -c, --compression       compression (default true)
  -d, --duration int      duration (default 10)
  -h, --headers string    request headers <string:string>
  -i, --insecure          insecure
  -k, --keepalives        keepalives (default true)
  -r, --requests int      count of requests per second (default 4)
  -t, --timeout int       timeout (default 10)
  -u, --url string        url to test

gopher@localhost→ httpbench www.google.com
Making 4 calls per second for 10 seconds...
Finished sending 4 requests...
Finished sending 8 requests...
Finished sending 12 requests...
Finished sending 16 requests...
Finished sending 20 requests...
Finished sending 24 requests...
Finished sending 28 requests...
Finished sending 32 requests...
Finished sending 36 requests...
Finished sending 40 requests...

----------------------------------
Total Requests: 40
Total Time Taken: 7.098961s
----------------------------------
fastest: 80.2569ms
slowest: 825.6611ms
average: 177.474025ms
----------------------------------
20x count: 40
30x count: 0
40x count: 0
50x count: 0

Help

If you need help or find a bug, submit an issue

To Do

  • Connections
  • headers
  • url tolower()
  • timeout
  • statistics
  • tests (we don't have 100% code coverage...)
  • body
  • finish readme
  • support custom ports
  • support common HTTP methods
  • allow user to specify number of concurrent connections or goroutines
  • custom user-agent string
  • change output format (json, csv, etc.)
  • proxy support/proxy authentication
  • authentication
  • cancellation on long requests (using a context)
  • skip SSL validation
  • override the host header
  • output version
  • verbose mode(?)
  • improve usage() function

Version History

  • 1.0.0
    • Initial Release

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dispatcher

func Dispatcher(reqChan chan *http.Request, duration int, requestsPerSecond int, u string, method string, body []byte, headers string, username string, password string) error

Dispatcher

func IsValidURL

func IsValidURL(url string) bool

func WorkerPool

func WorkerPool(reqChan chan *http.Request, respChan chan HTTPResponse, goroutines int, requestsPerSecond int, duration int, timeout int64, keepalives, compression bool, proxyAddress, proxyUser, proxyPass string, skipSSLValidation bool)

worker pool

Types

type HTTPResponse

type HTTPResponse struct {
	Latency time.Duration
	Status  int
	Err     error
}

type Statistics

type Statistics struct {
	TotalCalls            int           `json:"total_calls"`
	TotalTime             time.Duration `json:"total_time"`
	AvgTimePerRequest     time.Duration `json:"avg_time_per_request"`
	FastestRequest        time.Duration `json:"fastest_request"`
	SlowestRequest        time.Duration `json:"slowest_request"`
	TwoHundredResponses   int           `json:"two_hundreds"`
	ThreeHundredResponses int           `json:"three_hundreds"`
	FourHundredResponses  int           `json:"four_hundreds"`
	FiveHundredResponses  int           `json:"five_hundreds"`
}

func CalculateStatistics

func CalculateStatistics(responses []HTTPResponse) Statistics

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL