Skip to content

performance.now() returns incorrect value #17892

Closed

Description

@TimothyGu
  • Version: v9.x / master
  • Platform: all
  • Subsystem: perf_hooks
$ node -p 'perf_hooks.performance.now()'
174195586.611404

The spec (1 which leads to 2) describes the return value of performance.now() as:

the high resolution time from the time origin to the present time (typically called "now")

where time origin is defined as the point at which the "browsing context is first created", which translates to Node.js as the time Node.js is launched.

In other words, I would expect performance.now() to return a value close to 0 as it is executed as soon as Node.js is launched, rather than process.hrtime() converted to milliseconds as it currently does.

/cc @jasnell

Activity

  1. added
    perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.
    on Dec 28, 2017
  2. fhinkel commented on Jan 14, 2018

    @fhinkel
    Contributor

    AFAIK W3C isn't a spec for Node, but we try to match browser behavior as much as possible. Would we break anything in Node if we change time origin? How badly are we breaking the module ecosystems by introducing this change?

  3. TimothyGu commented on Jan 14, 2018

    @TimothyGu
    MemberAuthor

    W3C isn't a spec for Node, but we try to match browser behavior as much as possible

    The performance interface was written to conform to the W3C spec.

    Browsers all perform the way as described in the spec, but the recent Meltdown/Spectre mitigations include reducing performance's precision in general: w3c/hr-time#56

    Would we break anything in Node if we change time origin?

    Not that I am aware.

    How badly are we breaking the module ecosystems by introducing this change?

    I expect near-zero breakage since this is a relatively new API.

  4. self-assigned this
    on Feb 25, 2018
  5. added a commit that references this issue on May 8, 2018
  6. added a commit that references this issue on Aug 17, 2018
  7. added a commit that references this issue on Sep 6, 2018
  8. added a commit that references this issue on Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions