// speed returns the speed of the current file transfer
// in bytes per second, as well a an exponentially weighted moving average
// If no read has completed yet, 0 is returned for both values.
speed returns the speed of the current file transfer
in bytes per second, as well a an exponentially weighted moving average
If no read has completed yet, 0 is returned for both values.
// speed returns the speed of the current file transfer // in bytes per second as well a an exponentially weighted moving average // If no read has completed yet 0 is returned for both values .
func (acc *Account) speed() (bps, current float64) {
	if acc == nil {
		return 0, 0
	}
	acc.statmu.Lock()
	defer acc.statmu.Unlock()
	if acc.bytes == 0 {
		return 0, 0
	}
	total := float64(time.Now().Sub(acc.start)) / float64(time.Second)
	bps = float64(acc.bytes) / total
	current = acc.avg
	return
}
func ( acc * Account ) speed ( ) ( bps , current float64 ) { if acc == nil { return 0 , 0 } acc . statmu . Lock ( ) defer acc . statmu . Unlock ( ) if acc . bytes == 0 { return 0 , 0 } total := float64 ( time . Now ( ) . Sub ( acc . start ) ) / float64 ( time . Second ) bps = float64 ( acc . bytes ) / total current = acc . avg return }
speed returns the speed of the current file transfer
in bytes per second, as well a an exponentially weighted moving average
If no read has completed yet, 0 is returned for both values.
speed returns the speed of the current file transfer in bytes per second as well a an exponentially weighted moving average If no read has completed yet 0 is returned for both values .
// Calculate speed from first read.