GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — performance.getEntriesByType returns entries out of order · Issue #42024 · nodejs/node

performance.getEntriesByType returns entries out of order #42024

New issue
Copy link
New issue
Copy link
Closed
#42032
Closed
performance.getEntriesByType returns entries out of order#42024
#42032
Copy link
Labels
perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.Issues and PRs related to the perf_hooks module and performance measurement APIs.

Description

@nolanlawson
nolanlawson
opened on Feb 17, 2022
Issue body actions

Version

17.5.0

Platform

Linux 5.13.0-28-generic #31~20.04.1-Ubuntu SMP Wed Jan 19 14:08:10 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

perf_hooks

What steps will reproduce the bug?

Run this file (e.g. node index.js)

// index.js
(async () => {
  const sleep = ms => new Promise(resolve => setTimeout(() => resolve(), ms))

  performance.mark('one')
  await sleep(50)
  performance.mark('two')
  await sleep(50)
  performance.mark('three')
  await sleep(50)
  performance.measure('three', 'three')
  await sleep(50)
  performance.measure('two', 'two')
  await sleep(50)
  performance.measure('one', 'one')
  const entries = performance.getEntriesByType('measure')
  console.log(entries.map(x => x.name))
})()

How often does it reproduce? Is there a required condition?

Using the above code, it consistently reproduces for me. Perhaps in certain environments you may need a longer sleep time due to jitter.

What is the expected behavior?

If you run the same snippet in Chrome, Firefox, or Safari (e.g. in a DevTools Console on example.com), it will output:

['one', 'two', 'three']

According to MDN, getEntriesByType should return entries in order of startTime:

The items will be in chronological order based on the entries' startTime.

What do you see instead?

Node v16 and v17 will output:

[ 'three', 'two', 'one' ]

Additional information

No response

Activity

  1. Mesteery
    added
    perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.Issues and PRs related to the perf_hooks module and performance measurement APIs.
    on Feb 17, 2022
  2. benjamingr commented on Feb 17, 2022

    @benjamingr
    benjamingr
    on Feb 17, 2022
    Member
    More actions

    cc @gioragutt is this something you can fix while improving the performance of these APIs?

  3. gioragutt commented on Feb 17, 2022

    @gioragutt
    gioragutt
    on Feb 17, 2022
    Contributor
    More actions

    @benjamingr improve in what way? Reduce redundant code or something deeper?

  4. benjamingr commented on Feb 17, 2022

    @benjamingr
    benjamingr
    on Feb 17, 2022
    Member
    More actions

    @gioragutt they return the wrong order of entries - with the array/fixedqueue implementation this would just be adding a test for the case above and .reverseing the result (probably?)

  5. meixg commented on Feb 17, 2022

    @meixg
    meixg
    on Feb 17, 2022
    Member
    More actions

    @gioragutt they return the wrong order of entries - with the array/fixedqueue implementation this would just be adding a test for the case above and .reverseing the result (probably?)

    I guess it may need a sort by startTime.

  6. nodejs-github-bot
    closed this as completedin #42032on Feb 20, 2022
  7. nodejs-github-bot
    added a commit that references this issue on Feb 20, 2022

    perf_hooks: use arrays to store EntryBuffers

    6abd71e
  8. bengl
    added 5 commits that reference this issue on Feb 21, 2022

    perf_hooks: use arrays to store EntryBuffers

    777fb00

    perf_hooks: use arrays to store EntryBuffers

    008bace

    perf_hooks: use arrays to store EntryBuffers

    5ab5e9c

    perf_hooks: use arrays to store EntryBuffers

    fb750d6

    perf_hooks: use arrays to store EntryBuffers

    391f4e5
  9. danielleadams
    added 4 commits that reference this issue on Apr 21, 2022

    perf_hooks: use arrays to store EntryBuffers

    b044577

    perf_hooks: use arrays to store EntryBuffers

    b7a307f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    perf_hooksIssues and PRs related to the perf_hooks module and performance measurement APIs.Issues 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

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.