Skip to content

Commit

Permalink
fix: calculation lag
Browse files Browse the repository at this point in the history
  • Loading branch information
r3inbowari committed May 3, 2024
1 parent a200574 commit 2b0b519
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions speedtest/data_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,13 +260,15 @@ func (td *TestDirection) rateCapture() chan bool {
prevTotalDataVolume = newTotalDataVolume
if deltaDataVolume != 0 {
td.RateSequence = append(td.RateSequence, deltaDataVolume)
if td.captureCallback != nil {
globalAvg := (float64(td.totalDataVolume)) / float64(time.Since(sTime).Milliseconds()) * 1000
if td.welford.Update(globalAvg) {
go td.closeFunc()
}
td.captureCallback(td.welford.EWMA())
}
}
// anyway we update the measuring instrument
globalAvg := (float64(td.totalDataVolume)) / float64(time.Since(sTime).Milliseconds()) * 1000
if td.welford.Update(globalAvg) {
go td.closeFunc()
}
// reports the current rate at the given rate
if td.captureCallback != nil {
td.captureCallback(td.welford.EWMA())
}
case stop := <-stopCapture:
if stop {
Expand Down

0 comments on commit 2b0b519

Please sign in to comment.