Skip to content

JavaScript timing calculations could be more precise #106

@JohnRiv

Description

@JohnRiv

All of the timing calculations appear to only leverage Date.now()... It would be better to use User Timing and/or Resource Timing if the user's browser supports it, or High Resolution Timing if neither is supported. Reason being is if a system clock adjustment happens to occur when doing the timing, the results will be inaccurate. Plus those other APIs provide sub-millisecond timing data.

Only if High Resolution timing is not supported should you fall back to Date.now().

Surf-N-Perf can help streamline that for you if you want to simplify your code, and that supports older browsers that don't support Date.now() as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions