From ef70acad23a3edcbcf923fbca583b9688542aa2f Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Tue, 5 Nov 2013 15:08:06 +0000 Subject: [PATCH] added support for appending to results file and added Rate to result struct --- lib/attack.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/attack.go b/lib/attack.go index 31f4cae..f0bb13f 100644 --- a/lib/attack.go +++ b/lib/attack.go @@ -36,7 +36,7 @@ func drill(rate uint64, reqs chan *http.Request, res chan Result) { throttle := time.Tick(time.Duration(1e9 / rate)) for req := range reqs { <-throttle - go hit(req, res) + go hit(req, res, rate) } } @@ -51,13 +51,14 @@ var client = &http.Client{ // hit executes the passed http.Request and puts the result into results. // Both transport errors and unsucessfull requests (non {2xx,3xx}) are // considered errors. -func hit(req *http.Request, res chan Result) { +func hit(req *http.Request, res chan Result, rate uint64) { began := time.Now() r, err := client.Do(req) result := Result{ Timestamp: began, Latency: time.Since(began), BytesOut: uint64(req.ContentLength), + Rate: rate, } if err != nil { result.Error = err.Error()