Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/improve tracking of latency on page loads. #3773

Merged
merged 1 commit into from Jan 20, 2023
Merged

Fix/improve tracking of latency on page loads. #3773

merged 1 commit into from Jan 20, 2023

Conversation

dbrant
Copy link
Member

@dbrant dbrant commented Jan 20, 2023

We're currently using System.currentTimeMillis() for tracking the latency of page loads, which is actually not the appropriate thing to use in this case.
The currentTimeMillis() function gives us the "current time" of the device, which can actually change at any moment:

  • The device's clock might have drifted a bit, and suddenly receives an updated date/time from GPS or the network.
  • The user moves from one time zone into another.
  • The user changes the date/time on the device manually.

A much more appropriate function for measuring an "elapsed" time is the nanoTime() function, which gives the total nanoseconds of uptime for the current VM.

(Note that we should not be changing all instances of currentTimeMillis() into nanoTime(), since there are cases where currentTimeMillis() is more appropriate.)

@dbrant dbrant added Minor Minor stuff High Priority Priority code review needed labels Jan 20, 2023
@cooltey cooltey merged commit 0c94658 into main Jan 20, 2023
@cooltey cooltey deleted the latencyNanos branch January 20, 2023 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High Priority Priority code review needed Minor Minor stuff
2 participants