func()

in report/reporter.go [102:145]


func (r *Reporter) report() {
	ticker := time.NewTicker(r.reportDuration * time.Second)
	beg := time.Now()
	last_sent_time := beg
	last_sent := atomic.LoadInt64(&r.sendBytes)
	for {
		select {
		case <-ticker.C:
			now := time.Now()
			beg_duration := now.Sub(beg).Seconds()
			duration := now.Sub(last_sent_time).Seconds()
			last_sent_time = now

			sent := atomic.LoadInt64(&r.sendBytes)
			rate := int64(float64(sent-last_sent) / duration)
			total := r.fileSize
			progress := int(float64(float64(sent)/float64(total)) * 100)
			if progress >= 100 {
				progress = 100
			}
			last_sent = sent
			fill := 0

			fmt.Print("\r")
			fmt.Printf("Progress: [%s%s] %d%% Elapsed: %.2fs Rate: %s/s",
				getProgressBar(progress, 100, &fill),
				getEmptyBar(60-fill),
				progress,
				beg_duration,
				humanReadableBytes(rate))
			fmt.Print("\033[0K")
			// some worker may be failed.
			if progress == 100 || atomic.LoadUint64(&r.FinishedWorkers) == atomic.LoadUint64(&r.TotalWorkers) {
				fmt.Print("\nFinishing and publishing data ...\n")
				r.wg.Done()
				return
			}

		case <-r.closeCh:
			r.wg.Done()
			return
		}
	}
}