@@ -177,13 +177,13 @@ func (s *Server) PingAndJitter(count int) (float64, float64, error) {
177177}
178178
179179// Download performs the actual download test
180- func (s * Server ) Download (silent bool , useBytes , useMebi bool ) (float64 , int , error ) {
180+ func (s * Server ) Download (silent bool , useBytes , useMebi bool , requests int ) (float64 , int , error ) {
181181 t := time .Now ()
182182 defer func () {
183183 s .TLog .Logf ("Download took %s" , time .Now ().Sub (t ).String ())
184184 }()
185185
186- counter := & BytesCounter {}
186+ counter := NewCounter ()
187187 counter .SetMebi (useMebi )
188188
189189 ctx , cancel := context .WithCancel (context .Background ())
@@ -207,7 +207,7 @@ func (s *Server) Download(silent bool, useBytes, useMebi bool) (float64, int, er
207207 req .Header .Set ("User-Agent" , UserAgent )
208208 req .Header .Set ("Accept-Encoding" , "identity" )
209209
210- downloadDone := make (chan struct {})
210+ downloadDone := make (chan struct {}, requests )
211211
212212 doDownload := func () {
213213 resp , err := http .DefaultClient .Do (req )
@@ -249,7 +249,10 @@ func (s *Server) Download(silent bool, useBytes, useMebi bool) (float64, int, er
249249 }()
250250 }
251251
252- go doDownload ()
252+ for i := 0 ; i < requests ; i ++ {
253+ go doDownload ()
254+ time .Sleep (200 * time .Millisecond )
255+ }
253256 timeout := time .After (15 * time .Second )
254257Loop:
255258 for {
@@ -266,13 +269,13 @@ Loop:
266269}
267270
268271// Upload performs the actual upload test
269- func (s * Server ) Upload (noPrealloc , silent , useBytes , useMebi bool ) (float64 , int , error ) {
272+ func (s * Server ) Upload (noPrealloc , silent , useBytes , useMebi bool , requests int ) (float64 , int , error ) {
270273 t := time .Now ()
271274 defer func () {
272275 s .TLog .Logf ("Upload took %s" , time .Now ().Sub (t ).String ())
273276 }()
274277
275- counter := & BytesCounter {}
278+ counter := NewCounter ()
276279 counter .SetMebi (useMebi )
277280
278281 if noPrealloc {
@@ -299,7 +302,7 @@ func (s *Server) Upload(noPrealloc, silent, useBytes, useMebi bool) (float64, in
299302 req .Header .Set ("User-Agent" , UserAgent )
300303 req .Header .Set ("Accept-Encoding" , "identity" )
301304
302- uploadDone := make (chan struct {})
305+ uploadDone := make (chan struct {}, requests )
303306
304307 doUpload := func () {
305308 resp , err := http .DefaultClient .Do (req )
@@ -339,7 +342,10 @@ func (s *Server) Upload(noPrealloc, silent, useBytes, useMebi bool) (float64, in
339342 }()
340343 }
341344
342- go doUpload ()
345+ for i := 0 ; i < requests ; i ++ {
346+ go doUpload ()
347+ time .Sleep (200 * time .Millisecond )
348+ }
343349 timeout := time .After (15 * time .Second )
344350Loop:
345351 for {
0 commit comments