From 877d8b7528d8521480bc91e7f496d9d1a23d3ecd Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Mon, 31 Oct 2016 00:23:22 +0100 Subject: [PATCH 1/8] Improved @durple's User-Agent option. Added option to randomize URLs to be called. Added accept-encoding header option. --- gobench.go | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/gobench.go b/gobench.go index 21d1ca3..93a9550 100644 --- a/gobench.go +++ b/gobench.go @@ -15,6 +15,7 @@ import ( "sync" "sync/atomic" "time" + "math/rand" "github.com/valyala/fasthttp" ) @@ -31,6 +32,8 @@ var ( readTimeout int authHeader string userAgent string + acceptEnc string + randomize bool ) type Configuration struct { @@ -41,7 +44,8 @@ type Configuration struct { period int64 keepAlive bool authHeader string - userAgent string + acceptEnc string + randomize bool myClient fasthttp.Client } @@ -91,7 +95,9 @@ func init() { flag.IntVar(&writeTimeout, "tw", 5000, "Write timeout (in milliseconds)") flag.IntVar(&readTimeout, "tr", 5000, "Read timeout (in milliseconds)") flag.StringVar(&authHeader, "auth", "", "Authorization header") - flag.StringVar(&userAgent, "agent", "", "User-Agent") + flag.StringVar(&userAgent, "agent", "", "User-Agent header") + flag.StringVar(&acceptEnc, "accept", "", "Accept-Encoding header") + flag.BoolVar(&randomize, "random", false, "Randomize URL order") } func printResults(results map[int]*Result, startTime time.Time) { @@ -179,7 +185,8 @@ func NewConfiguration() *Configuration { keepAlive: keepAlive, requests: int64((1 << 63) - 1), authHeader: authHeader, - userAgent: userAgent} + acceptEnc: acceptEnc, + randomize: randomize} if period != -1 { configuration.period = period @@ -235,6 +242,7 @@ func NewConfiguration() *Configuration { configuration.myClient.ReadTimeout = time.Duration(readTimeout) * time.Millisecond configuration.myClient.WriteTimeout = time.Duration(writeTimeout) * time.Millisecond configuration.myClient.MaxConnsPerHost = clients + configuration.myClient.Name = userAgent configuration.myClient.Dial = MyDialer() @@ -255,8 +263,15 @@ func MyDialer() func(address string) (conn net.Conn, err error) { } func client(configuration *Configuration, result *Result, done *sync.WaitGroup) { + rand := rand.New(rand.NewSource(time.Now().UnixNano())) for result.requests < configuration.requests { - for _, tmpUrl := range configuration.urls { + var tmpUrls []string; + if (configuration.randomize) { + tmpUrls = []string{configuration.urls[rand.Intn(len(configuration.urls))]} + } else { + tmpUrls = configuration.urls + } + for _, tmpUrl := range tmpUrls { req := fasthttp.AcquireRequest() @@ -273,8 +288,8 @@ func client(configuration *Configuration, result *Result, done *sync.WaitGroup) req.Header.Set("Authorization", configuration.authHeader) } - if len(configuration.userAgent) > 0 { - req.Header.Set("User-Agent", configuration.userAgent) + if len(configuration.acceptEnc) > 0 { + req.Header.Set("Accept-Encoding", configuration.acceptEnc) } req.SetBody(configuration.postData) From 9a3bbe67878ceb0cf297a1b3fc93905c1d829dbb Mon Sep 17 00:00:00 2001 From: Root on server shade Date: Sat, 24 Mar 2018 23:57:56 +0100 Subject: [PATCH 2/8] Added `-insecure=1` option to skip checking SSL certificates --- gobench.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gobench.go b/gobench.go index 93a9550..e182660 100644 --- a/gobench.go +++ b/gobench.go @@ -16,10 +16,12 @@ import ( "sync/atomic" "time" "math/rand" + "crypto/tls" "github.com/valyala/fasthttp" ) +// Global variables var ( requests int64 period int64 @@ -34,8 +36,10 @@ var ( userAgent string acceptEnc string randomize bool + insecure bool ) +// Benchmark Client Configuration type Configuration struct { urls []string method string @@ -98,6 +102,7 @@ func init() { flag.StringVar(&userAgent, "agent", "", "User-Agent header") flag.StringVar(&acceptEnc, "accept", "", "Accept-Encoding header") flag.BoolVar(&randomize, "random", false, "Randomize URL order") + flag.BoolVar(&insecure, "insecure", false, "Skip verifing SSL certificate") } func printResults(results map[int]*Result, startTime time.Time) { @@ -243,6 +248,7 @@ func NewConfiguration() *Configuration { configuration.myClient.WriteTimeout = time.Duration(writeTimeout) * time.Millisecond configuration.myClient.MaxConnsPerHost = clients configuration.myClient.Name = userAgent + configuration.myClient.TLSConfig = &tls.Config{ InsecureSkipVerify: insecure } configuration.myClient.Dial = MyDialer() From 9e8aa4f8cb666dedc75a8194b08cb977a07e7326 Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Sun, 6 Sep 2020 22:08:57 +0200 Subject: [PATCH 3/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac3a942..ce009f4 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Usage ================ 1. download gobench - ```go get github.com/cmpxchg16/gobench``` + ```go get github.com/jeroenvermeulen/gobench``` 1. run some http server on port 80 2. run gobench for HTTP GET From 16952dfb5ac7db6068f18ee2c2389273f275bca9 Mon Sep 17 00:00:00 2001 From: "Root on server siege.magehost.pro" Date: Sun, 6 Sep 2020 23:06:53 +0200 Subject: [PATCH 4/8] Enabled display of error messages + increased ReadBufferSize to 16k --- gobench.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gobench.go b/gobench.go index e182660..726c370 100644 --- a/gobench.go +++ b/gobench.go @@ -244,6 +244,7 @@ func NewConfiguration() *Configuration { configuration.postData = data } + configuration.myClient.ReadBufferSize = 16384 configuration.myClient.ReadTimeout = time.Duration(readTimeout) * time.Millisecond configuration.myClient.WriteTimeout = time.Duration(writeTimeout) * time.Millisecond configuration.myClient.MaxConnsPerHost = clients @@ -308,6 +309,7 @@ func client(configuration *Configuration, result *Result, done *sync.WaitGroup) fasthttp.ReleaseResponse(resp) if err != nil { + fmt.Printf("ERROR: %+v\n", err) result.networkFailed++ continue } From 34ba4557d6933422648e76c79028c5df0188d9df Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Wed, 15 May 2024 14:17:45 +0200 Subject: [PATCH 5/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce009f4..b0195be 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Usage ================ 1. download gobench - ```go get github.com/jeroenvermeulen/gobench``` + ```go install github.com/jeroenvermeulen/gobench@latest``` 1. run some http server on port 80 2. run gobench for HTTP GET From 23e5bf42088175a4f7571e5f4a508ee2164751e1 Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Wed, 15 May 2024 14:18:19 +0200 Subject: [PATCH 6/8] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b0195be..eea4b57 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ The funny part - I did some benchmark to the client tester tool and not to the s ###Siege: - $>siege -b -t10S -c500 http://localhost:80/ + $ siege -b -t10S -c500 http://localhost:80/ ** SIEGE 2.70 ** Preparing 500 concurrent users for battle. @@ -39,7 +39,7 @@ The funny part - I did some benchmark to the client tester tool and not to the s ###GoBench: - $>gobench -k=true -u http://localhost:80 -c 500 -t 10 + $ gobench -k=true -u http://localhost:80 -c 500 -t 10 Dispatching 500 clients Waiting for results... @@ -66,11 +66,11 @@ Usage 1. run some http server on port 80 2. run gobench for HTTP GET - ```$>gobench -u http://localhost:80 -k=true -c 500 -t 10``` + ```$ gobench -u http://localhost:80 -k=true -c 500 -t 10``` 3. run gobench for HTTP POST - ```$>gobench -u http://localhost:80 -k=true -c 500 -t 10 -d /tmp/post``` + ```$ gobench -u http://localhost:80 -k=true -c 500 -t 10 -d /tmp/post``` Notes From 825cfd138f74d8ad74c81711cd978d76d11d13f2 Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Wed, 15 May 2024 14:39:33 +0200 Subject: [PATCH 7/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eea4b57..a6b6c44 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Notes ================ 2. Because it's a test tool, in HTTPS the ceritificate verification is insecure -3. use Go >= 1.5 (fasthttp require it) +3. use Go >= 1.20 (fasthttp require it) Help ================ From d8140845a8434c6a6d399463be4c30b9046d551b Mon Sep 17 00:00:00 2001 From: Jeroen Vermeulen Date: Wed, 15 May 2024 14:39:43 +0200 Subject: [PATCH 8/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a6b6c44..f2f391c 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Notes ================ 2. Because it's a test tool, in HTTPS the ceritificate verification is insecure -3. use Go >= 1.20 (fasthttp require it) +3. use Go >= 1.20 (fasthttp requires it) Help ================