Skip to content

performance.timerify(fn, options) always return the same timerifed function #42742

Closed
@hax

Description

@hax

Version

master branch

Platform

All

Subsystem

perf_hooks

What steps will reproduce the bug?

function f() {}
let h1 = perf_hooks.createHistogram()
let h2 = perf_hooks.createHistogram()
let f1 = perf_hooks.performance.timerify(f, {histogram: h1})
let f2 = perf_hooks.performance.timerify(f, {histogram: h2})
f1 !== f2 // expect true, actual false

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

Always

What is the expected behavior?

Every calls of performance.timerify(fn) should return a new timerified function instance for fn, at least if options is provided.

What do you see instead?

Currently timerify will cache the timerfied function as fn[kTimerified], so timerify(fn) always return same timerified function for fn, even different options was given.

Additional information

Current cache behavior is not very useful, and cause problems for the use cases which need multiple timerified versions (for example, record timing for different usage of the same function).

PS. It also will throw if fn is frozen/sealed/non-extensible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.perf_hooksIssues and PRs related to the implementation of the Performance Timing API.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions