Skip to content

Commit 629536d

Browse files
Merge pull request #13 from systay/dropped-samples
Do not forget dropped samples
2 parents dfbf8d2 + 48803e5 commit 629536d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

measurements/immutable_sample_window.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (s *ImmutableSampleWindow) AddSample(startTime int64, rtt int64, maxInFligh
6262
if startTime < 0 {
6363
startTime = time.Now().UnixNano()
6464
}
65-
return NewImmutableSampleWindow(startTime, minRTT, s.sum+rtt, maxInFlight, s.sampleCount+1, false)
65+
return NewImmutableSampleWindow(startTime, minRTT, s.sum+rtt, maxInFlight, s.sampleCount+1, s.didDrop)
6666
}
6767

6868
// AddDroppedSample will create a new immutable sample that was dropped.

measurements/immutable_sample_window_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ func TestImmutableSampleWindow(t *testing.T) {
2222
"ImmutableSampleWindow{minRTT=10, averageRTT=10, maxInFlight=5, sampleCount=1, didDrop=false}",
2323
w2.String(),
2424
)
25+
26+
// Adding a dropped sample should mark the window as having contained dropped tokens
2527
w3 := w2.AddDroppedSample(-10, 500)
2628
asrt.True(w3.DidDrop())
29+
30+
// Adding a successful sample should not void the dropped marker on the window
31+
w4 := w3.AddSample(10, 10, 5)
32+
asrt.True(w4.DidDrop())
2733
}

0 commit comments

Comments
 (0)