← All notes

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

See also

Claims

Sources

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

Permanent ID: iil:note:5qpgfgfx

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.},
}

Markdown

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.