Make rate estimator estimate packet rates too.

This commit is contained in:
Juliusz Chroboczek
2020-06-03 22:37:43 +02:00
parent 19a65318c9
commit 4da03a3ce5
4 changed files with 43 additions and 16 deletions
+15 -1
View File
@@ -13,11 +13,14 @@ func TestEstimator(t *testing.T) {
e.Accumulate(42)
e.Accumulate(128)
e.estimate(now.Add(time.Second))
rate := e.estimate(now.Add(time.Second + time.Millisecond))
rate, packetRate := e.estimate(now.Add(time.Second + time.Millisecond))
if rate != 42+128 {
t.Errorf("Expected %v, got %v", 42+128, rate)
}
if packetRate != 2 {
t.Errorf("Expected 2, got %v", packetRate)
}
totalP, totalB := e.Totals()
if totalP != 2 {
@@ -26,4 +29,15 @@ func TestEstimator(t *testing.T) {
if totalB != 42+128 {
t.Errorf("Expected %v, got %v", 42+128, totalB)
}
e.Accumulate(12)
totalP, totalB = e.Totals()
if totalP != 3 {
t.Errorf("Expected 2, got %v", totalP)
}
if totalB != 42+128+12 {
t.Errorf("Expected %v, got %v", 42+128, totalB)
}
}