Closed
Description
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.