Node.js perf_hooks - performance.now, timerify and PerformanceObserver
Answer: performance.now() returns the current high resolution millisecond timestamp, measured from an origin in this process. PerformanceObserver collects performance entries. timerify wraps a function in a new function that measures the running time of the wrapped function.
Examples
import { performance, PerformanceObserver, timerify } from 'node:perf_hooks';
const t0 = performance.now();
// ... work ...
console.log(performance.now() - t0, 'ms');
const obs = new PerformanceObserver((list) => {
for (const entry of list.getEntries()) console.log(entry.name, entry.duration);
});
obs.observe({ entryTypes: ['function', 'measure'] });
const wrapped = timerify(function work() { /* ... */ });
wrapped();
performance.mark('a');
performance.mark('b');
performance.measure('a to b', 'a', 'b');
Rules
performance.markcreates a new PerformanceMark entry in the Performance Timeline.
See also
Claims
- id: C1 claim: performance.now returns a high-resolution millisecond timestamp. source: S2 evidence: "Returns the current high resolution millisecond timestamp"
- id: C2 claim: PerformanceObserver receives performance entries. source: S1 evidence: "PerformanceObserver"
- id: C3 claim: Marks are created in the Performance Timeline. source: S2 evidence: "Creates a new
PerformanceMarkentry in the Performance Timeline"
Sources
- [S1] Performance measurement APIs. Node.js API docs. https://nodejs.org/api/perf_hooks.html . License: MIT. Accessed 2026-11-18.
- [S2] doc/api/perf_hooks.md. nodejs/node (GitHub). https://github.com/nodejs/node/blob/main/doc/api/perf_hooks.md . License: MIT. Accessed 2026-11-18.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Node.js API docs, Performance measurement APIs; nodejs/node (GitHub), doc/api/perf_hooks.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Node.js API docs, Performance measurement APIs; nodejs/node (GitHub), doc/api/perf_hooks.md. MIT (https://raw.githubusercontent.com/nodejs/node/main/LICENSE). Copyright Node.js contributors.
Cite this
iinventedlight. 2026. "Node.js perf_hooks - performance.now, timerify and PerformanceObserver." iinventedlight Library, iil:note:5qpgfgfx, version of 2026-11-18. https://iinventedlight.com/library/notes/node-perf-hooks/. License: CC-BY-4.0.
@misc{iil_note_5qpgfgfx,
author = {{iinventedlight}},
title = {{Node.js perf\_hooks - performance.now, timerify and PerformanceObserver}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-18},
url = {https://iinventedlight.com/library/notes/node-perf-hooks/},
note = {Permanent ID iil:note:5qpgfgfx. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/node-perf-hooks.md.