HTTP load generator, ApacheBench (ab) replacement
Go
Code reorg.
Burcu Doganc93039a92f6b
diff --git a/commands/boom.go b/commands/boom.goindex 33e340c..485e0c5 100644--- a/commands/boom.go+++ b/commands/boom.go@@ -10,7 +10,7 @@ import (type result struct {err errorstatusCode int- dur time.Duration+ duration time.Duration}type Boom struct {@@ -19,10 +19,8 @@ type Boom struct {C intClient *http.Client- start time.Time- end time.Time-- bar *pb.ProgressBar-+ start time.Time+ end time.Timeresults chan *result+ bar *pb.ProgressBar}diff --git a/commands/print.go b/commands/print.goindex 42867d4..23edd38 100644--- a/commands/print.go+++ b/commands/print.go@@ -18,12 +18,12 @@ func (b *Boom) Print() {case r := <-b.results:statusCodeDist[r.statusCode]++- avgTotal += r.dur.Nanoseconds()- if fastest.Nanoseconds() == 0 || r.dur.Nanoseconds() < fastest.Nanoseconds() {- fastest = r.dur+ avgTotal += r.duration.Nanoseconds()+ if fastest.Nanoseconds() == 0 || r.duration.Nanoseconds() < fastest.Nanoseconds() {+ fastest = r.duration}- if r.dur.Nanoseconds() > slowest.Nanoseconds() {- slowest = r.dur+ if r.duration.Nanoseconds() > slowest.Nanoseconds() {+ slowest = r.duration}default:rps := float64(b.N) / total.Seconds()diff --git a/commands/run.go b/commands/run.goindex dc1b2ca..5dc7202 100644--- a/commands/run.go+++ b/commands/run.go@@ -65,5 +65,9 @@ func (b *Boom) runOneReq() {if resp != nil {code = resp.StatusCode}- b.results <- &result{statusCode: code, err: err, dur: time.Now().Sub(s)}+ b.results <- &result{+ statusCode: code,+ duration: time.Now().Sub(s),+ err: err,+ }}