We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ed1d512 commit f5ce273Copy full SHA for f5ce273
task/download.go
@@ -167,10 +167,15 @@ func downloadHandler(ip *net.IPAddr) float64 {
167
}
168
bufferRead, err := response.Body.Read(buffer)
169
if err != nil {
170
- if err != io.EOF { // 文件下载完了,或因网络等问题导致链接中断,则退出循环(终止测速)
+ // 获取上个时间片
171
+ last_time_slice := timeStart.Add(timeSlice * time.Duration(timeCounter-1))
172
+ // 下载数据量 / (用当前时间 - 上个时间片/ 时间片)
173
+ e.Add(float64(contentRead-lastContentRead) / (float64(currentTime.Sub(last_time_slice)) / float64(timeSlice)))
174
+
175
+ if err == io.EOF { // 文件下载完了,或因网络等问题导致链接中断,则退出循环(终止测速)
176
break
177
- e.Add(float64(contentRead-lastContentRead) / (float64(nextTime.Sub(currentTime)) / float64(timeSlice)))
178
179
180
contentRead += int64(bufferRead)
181
0 commit comments