w3c / performance-timeline

Performance Timeline
https://w3c.github.io/performance-timeline/
Other
111 stars 27 forks source link

Gsoc 2023 Proposal clock-drift correction #208

Closed Forchapeatl closed 1 year ago

Forchapeatl commented 1 year ago

image

Please , correct me if I am wrong / mislead

when it comes to measuring the time taken for a task to accomplish results we can use the system clock Date.now()

var mark_start = Date.now();
doTask(); // Some task
var duration = Date.now() - mark_start;

But the difference between start-end using Date.now() can't be trusted as a change in the user's system time would skew the results.

var mark_start = performance.now();
doTask(); // Some task
var duration = performance.now() - mark_start;

Similarly we can use the monotonic clock Performance.now() - which relative to page load . But a difference between start-end of performance.now() can't be used as the underlying clock potentially stops if the user sleeps their device.

Hence we need to account for time which is reliable across sleep / wake cycles during task execution.

clockOffset = new Date() - performance.timeOrigin - performance.now()

Options (1) is fine if you ask me. Since we are accounting for two different clocks option (2) might cost confusion as the drift behavior is different on platforms. Option (3) seems to require the some replication of entry attributes and seems more complex than it sounds.

Just to clarify , option (1) means the PerformanceEntry will have 5 attributes: name, entryType,startTime, duration and clockOffset ?

Originally posted by @Forchapeatl in https://github.com/w3c/performance-timeline/issues/206#issuecomment-1459614219

Forchapeatl commented 1 year ago

Hello @noamr , as a result of this comment . Please , I don't really know how to approach you in regards to gsoc. I thought it will be better to respectfully create a new issue to address my worries. Please , is this okay with you ?

noamr commented 1 year ago

Hello @noamr , as a result of this comment . Please , I don't really know how to approach you in regards to gsoc. I thought it will be better to respectfully create a new issue to address my worries. Please , is this okay with you ?

Please go through the standard GSOC process and don't post here as requested.