This commit is contained in:
@@ -280,6 +280,17 @@ func qualificationMediaPacerKbps(profile qualificationMediaProfile, reduction in
|
||||
return (payloadKbps*int64(profile.PacketBytes+frameHeaderSize) + int64(profile.PacketBytes) - 1) / int64(profile.PacketBytes)
|
||||
}
|
||||
|
||||
func qualificationBoundedRelease(target, next, now time.Time, spacing time.Duration) time.Time {
|
||||
release := target
|
||||
if next.After(release) {
|
||||
release = next
|
||||
}
|
||||
if now.Sub(release) > spacing {
|
||||
return now.Add(-spacing)
|
||||
}
|
||||
return release
|
||||
}
|
||||
|
||||
type qualificationTracingBackend struct {
|
||||
native *NativeApolloBackend
|
||||
setups atomic.Uint64
|
||||
@@ -1326,20 +1337,13 @@ func runQualificationImpairment(t *testing.T, profile qualificationImpairmentPro
|
||||
|
||||
stepAt := make(map[int]time.Time, len(profile.CapacitySteps))
|
||||
emitted := 0
|
||||
var previousRelease time.Time
|
||||
maxCatchup := spacing
|
||||
var nextRelease time.Time
|
||||
for _, packet := range jobs {
|
||||
release := started.Add(packet.target)
|
||||
if minimum := previousRelease.Add(spacing); !previousRelease.IsZero() && release.Before(minimum) {
|
||||
release = minimum
|
||||
}
|
||||
if lag := time.Since(release); lag > maxCatchup {
|
||||
release = release.Add(lag - maxCatchup)
|
||||
}
|
||||
release := qualificationBoundedRelease(started.Add(packet.target), nextRelease, time.Now(), spacing)
|
||||
if delay := time.Until(release); delay > 0 {
|
||||
time.Sleep(delay)
|
||||
}
|
||||
previousRelease = release
|
||||
nextRelease = release.Add(spacing)
|
||||
if len(profile.CapacitySteps) == 2 {
|
||||
switch {
|
||||
case packet.index >= packetCount*2/3 && stepAt[profile.CapacitySteps[1]].IsZero():
|
||||
|
||||
Reference in New Issue
Block a user