Skip to content

Commit

Permalink
Merge pull request #13 from systay/dropped-samples
Browse files Browse the repository at this point in the history
Do not forget dropped samples
  • Loading branch information
platinummonkey committed Apr 4, 2019
2 parents dfbf8d2 + 48803e5 commit 629536d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion measurements/immutable_sample_window.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (s *ImmutableSampleWindow) AddSample(startTime int64, rtt int64, maxInFligh
if startTime < 0 {
startTime = time.Now().UnixNano()
}
return NewImmutableSampleWindow(startTime, minRTT, s.sum+rtt, maxInFlight, s.sampleCount+1, false)
return NewImmutableSampleWindow(startTime, minRTT, s.sum+rtt, maxInFlight, s.sampleCount+1, s.didDrop)
}

// AddDroppedSample will create a new immutable sample that was dropped.
Expand Down
6 changes: 6 additions & 0 deletions measurements/immutable_sample_window_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ func TestImmutableSampleWindow(t *testing.T) {
"ImmutableSampleWindow{minRTT=10, averageRTT=10, maxInFlight=5, sampleCount=1, didDrop=false}",
w2.String(),
)

// Adding a dropped sample should mark the window as having contained dropped tokens
w3 := w2.AddDroppedSample(-10, 500)
asrt.True(w3.DidDrop())

// Adding a successful sample should not void the dropped marker on the window
w4 := w3.AddSample(10, 10, 5)
asrt.True(w4.DidDrop())
}

0 comments on commit 629536d

Please sign in to comment.