refactor(client): use SignedDuration for effective RTT to support negative values
Simplify RttSample by merging signed and unsigned fields into a single SignedDuration for adjusted and effective RTT. This ensures accurate reporting and statistics when server processing time exceeds raw RTT.
This commit is contained in:
1 parent
37de7c96a1
commit
bec56d4114
14 files changed
+207
-86
No files matched your search
@@ -727,22 +727,15 @@ fn compute_rtt(
|
||||
|
||||
let server_processing = compute_server_processing(ts);
|
||||
|
||||
let adjusted = server_processing.and_then(|sp| raw.checked_sub(sp));
|
||||
|
||||
let effective = adjusted.unwrap_or(raw);
|
||||
let adjusted_signed = server_processing.map(|sp| SignedDuration {
|
||||
let adjusted = server_processing.map(|sp| SignedDuration {
|
||||
ns: duration_ns_i128(raw) - duration_ns_i128(sp),
|
||||
});
|
||||
let effective_signed = adjusted_signed.unwrap_or(SignedDuration {
|
||||
ns: duration_ns_i128(raw),
|
||||
});
|
||||
let effective = adjusted.unwrap_or_else(|| SignedDuration::from_duration(raw));
|
||||
|
||||
RttSample {
|
||||
raw,
|
||||
adjusted,
|
||||
effective,
|
||||
adjusted_signed,
|
||||
effective_signed,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user