Skip to content

fix: keep sub-millisecond precision in ping and jitter - #129

Merged
maddie merged 1 commit into
librespeed:masterfrom
BKPepe:fix/sub-millisecond-ping-precision
Aug 11, 2026
Merged

fix: keep sub-millisecond precision in ping and jitter#129
maddie merged 1 commit into
librespeed:masterfrom
BKPepe:fix/sub-millisecond-ping-precision

Conversation

@BKPepe

@BKPepe BKPepe commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Duration.Milliseconds truncates to whole milliseconds, and every round-trip
sample went through it — in the ICMP path and in the TCP fallback that
--no-icmp selects. On a link faster than a millisecond that leaves nothing.

Against a server on loopback, reporting only ping and jitter:

ping jitter
before 0 0
after 0.11 0.01

Over a wider link the reported ping still looks fractional, because it is an
average of the samples — but its resolution is a whole millisecond, and jitter
is a difference of those samples. Three consecutive ICMP runs against the same
server:

ping jitter
before 5, 6, 5 0.59, 4.40, 0.02
after 5.48, 5.68, 5.45 0.27, 0.32, 0.12

Dividing by time.Millisecond keeps the fraction.

Copilot AI lite review requested due to automatic review settings August 9, 2026 23:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@BKPepe
BKPepe force-pushed the fix/sub-millisecond-ping-precision branch 2 times, most recently from 05013a8 to dead4b8 Compare August 11, 2026 08:32
Duration.Milliseconds truncates to whole milliseconds, and every round-trip
sample went through it -- in the ICMP path and in the TCP fallback that
--no-icmp selects. On a link faster than a millisecond that leaves nothing.

Against a server on loopback, reporting only ping and jitter:

  before   ping 0     jitter 0
  after    ping 0.11  jitter 0.01

Over a wider link the reported ping still looks fractional, because it is an
average of the samples, but its resolution is a whole millisecond and jitter
is a difference of those samples. Three consecutive ICMP runs against the
same server:

  before   ping 5, 6, 5          jitter 0.59, 4.40, 0.02
  after    ping 5.48, 5.68, 5.45 jitter 0.27, 0.32, 0.12

Divide by time.Millisecond instead, which keeps the fraction.
@BKPepe
BKPepe force-pushed the fix/sub-millisecond-ping-precision branch from dead4b8 to 3144947 Compare August 11, 2026 08:44
@maddie
maddie merged commit e13a3e4 into librespeed:master Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants