handle nan, inf
This commit is contained in:
4
rtt.go
4
rtt.go
@@ -124,6 +124,10 @@ func (cp *ContinuousPinger) Stats(dSent, dReceive int) (*PingStats, error) {
|
||||
}
|
||||
ps.AvgRtt = time.Duration(sum / int64(pkgsInArr))
|
||||
ps.PacketLoss = math.Min(100, math.Max(100-(float64(dReceive)/float64(dSent)*100), 0))
|
||||
if math.IsNaN(ps.PacketLoss) || math.IsInf(ps.PacketLoss, 0) {
|
||||
ps.PacketLoss = 100
|
||||
}
|
||||
|
||||
stdDev, err := stats.StandardDeviation(rttArray)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Reference in New Issue
Block a user