HTTP load generator, ApacheBench (ab) replacement
Go
Added Total Data Transferred to output
Vasilis Keramidasf750cf989fa1
diff --git a/commands/boom.go b/commands/boom.goindex 6b30b38..11c161d 100644--- a/commands/boom.go+++ b/commands/boom.go@@ -27,6 +27,7 @@ type result struct {err errorstatusCode intduration time.Duration+ ContentLength int64}type ReqOpts struct {diff --git a/commands/print.go b/commands/print.goindex d651b21..911cac5 100644--- a/commands/print.go+++ b/commands/print.go@@ -38,6 +38,7 @@ type report struct {statusCodeDist map[int]intlats []float64errors map[string]int+ sizeTotal int64output string}@@ -61,6 +62,7 @@ func (r *report) finalize(total time.Duration) {r.lats = append(r.lats, res.duration.Seconds())r.avgTotal += res.duration.Seconds()r.statusCodeDist[res.statusCode]+++ r.sizeTotal += res.ContentLength}default:r.total = total@@ -89,6 +91,7 @@ func (r *report) print() {fmt.Printf(" Fastest:\t%4.4f secs.\n", r.fastest)fmt.Printf(" Average:\t%4.4f secs.\n", r.average)fmt.Printf(" Requests/sec:\t%4.4f\n", r.rps)+ fmt.Printf(" Total Data Transferred:\t%d bytes.\n", r.sizeTotal)r.printStatusCodes()r.printHistogram()r.printLatencies()@@ -166,6 +169,7 @@ func (r *report) printStatusCodes() {}}+func (r *report) printErrors() {fmt.Printf("\nError distribution:\n")for error, num := range r.errors {diff --git a/commands/run.go b/commands/run.goindex 15283ae..2aebc78 100644--- a/commands/run.go+++ b/commands/run.go@@ -41,8 +41,10 @@ func (b *Boom) worker(ch chan *http.Request) {s := time.Now()resp, err := client.Do(req)code := 0+ var size int64 = 0if resp != nil {code = resp.StatusCode+ size = resp.ContentLength// cleanup body, so the socket can be reusableresp.Body.Close()}@@ -53,6 +55,7 @@ func (b *Boom) worker(ch chan *http.Request) {statusCode: code,duration: time.Now().Sub(s),err: err,+ ContentLength: size,}}}