- for i := 0; i < iter; i++ {
- rate := measureRequest(client, down, measurementBytes)
- fmt.Printf("Down: MiB/s %v\n", rate/MiB)
+ go measureNRequests(iter, client, func() *http.Request { return down }, bytes, downChan)
+ go measureNRequests(iter, client, func() *http.Request { return getUp(uUrl, bytes) }, bytes, upChan)
+ tickChan := make(chan rune)
+ go func() {
+ for {
+ for _, char := range "|/-\\" {
+ time.Sleep(100 * time.Millisecond)
+ tickChan <- char
+ }
+ }
+ }()
+
+downChannel:
+ for {
+ select {
+ case rate, ok := <-downChan:
+ if !ok {
+ fmt.Println("\rRunning download tests: done!")
+ break downChannel
+ }
+ downRates = append(downRates, rate)
+ case spinner := <-tickChan:
+ fmt.Printf("\rRunning download tests: %c", spinner)
+ }