{"$schema":"https://doc-kit.nodejs.org/schemas/api-doc/1.0.1.json","id":"bench","path":"/bench","type":"module","module":"bench","title":"Benchmark runner","introducedIn":"v26.9.0","sourceLink":{"path":"lib/bench.js","url":"https://github.com/nodejs/node/blob/HEAD/lib/bench.js"},"stability":{"index":"1.0","description":"Early Development"},"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `node:bench` module supports defining and running JavaScript benchmarks in\nthe current process, and running one benchmark file in a fresh child process.\nThe module is only available when Node.js is started with the\n`--experimental-bench` flag and can only be imported with the `node:` scheme:\n\n```mjs\nimport { bench, suite } from 'node:bench';\n```\n\n```cjs\nconst { bench, suite } = require('node:bench');\n```","summary":"The `node:bench` module supports defining and running JavaScript benchmarks in the current process, and running one benchmark file in a fresh child process. The module is only available when Node.js is started with the `--experimental-bench` flag and can only be imported with the `node:` scheme:","examples":[{"language":"mjs","displayName":null,"code":"import { bench, suite } from 'node:bench';"},{"language":"cjs","displayName":null,"code":"const { bench, suite } = require('node:bench');"}],"children":[{"kind":"section","id":"example-benchmark","name":"Example benchmark","title":"Example benchmark","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Save the following as `benchmark.mjs`:\n\n```mjs\nimport { bench, suite } from 'node:bench';\n\nsuite('URL', () => {\n  const input = 'https://example.com/a?b=c';\n\n  bench('construct', {\n    samples: 30,\n    params: { input: 'short' },\n  }, (b) => {\n    const operations = 10_000;\n    let totalLength = 0;\n\n    b.start();\n    for (let i = 0; i < operations; i++) {\n      totalLength += new URL(input).href.length;\n    }\n    b.end(operations);\n\n    if (totalLength !== operations * input.length) {\n      throw new Error('Unexpected URL result');\n    }\n  });\n});\n```\n\nRun the benchmark from the command line:\n\n```console\nnode --experimental-bench --bench benchmark.mjs\n```\n\nBenchmarks are executed serially in declaration order. Declared benchmarks are\nscheduled automatically. Call `run()` during the same turn as the declarations\nto consume the event stream or configure filtering.\nIf an automatically scheduled run fails and `run()` was not called, the process\nexit code is set to `1`.","summary":"Save the following as `benchmark.mjs`:","examples":[{"language":"mjs","displayName":null,"code":"import { bench, suite } from 'node:bench';\n\nsuite('URL', () => {\n  const input = 'https://example.com/a?b=c';\n\n  bench('construct', {\n    samples: 30,\n    params: { input: 'short' },\n  }, (b) => {\n    const operations = 10_000;\n    let totalLength = 0;\n\n    b.start();\n    for (let i = 0; i < operations; i++) {\n      totalLength += new URL(input).href.length;\n    }\n    b.end(operations);\n\n    if (totalLength !== operations * input.length) {\n      throw new Error('Unexpected URL result');\n    }\n  });\n});"},{"language":"console","displayName":null,"code":"node --experimental-bench --bench benchmark.mjs"}],"children":[]},{"kind":"section","id":"measurement-model","name":"Measurement model","title":"Measurement model","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Each warmup and measured sample invokes the benchmark function once with a\nfresh {BenchContext}. The function must either call `context.start()` and\n`context.end(operations)` exactly once, or call `context.record(sample)` exactly\nonce to provide an externally measured sample. Setup before `start()` and\ncleanup after `end()` are outside the measured region. Promise-returning\nfunctions are awaited.\n\nBy default, an event loop turn occurs between sample invocations. An embedded\nrunner can disable this using `yieldBetweenSamples`. The runner executes\nbenchmarks serially, but it does not provide process isolation. Other work in\nthe process, JIT compilation, garbage collection, CPU frequency changes, and\nsystem load can all affect results. Keep raw samples when comparing results and\ninvestigate noisy or skewed distributions rather than treating a confidence\ninterval as a pass/fail threshold.","summary":"Each warmup and measured sample invokes the benchmark function once with a fresh {BenchContext}. The function must either call `context.start()` and `context.end(operations)` exactly once, or call `context.record(sample)` exactly once to provide an externally measured sample. Setup before `start()` and cleanup after `end()` are outside the measured region. Promise-returning functions are awaited.","examples":[],"children":[{"kind":"section","id":"measurement-integrity","name":"Measurement integrity","title":"Measurement integrity","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"A statistically consistent result does not prove that a benchmark measured the\nintended work. An optimizing runtime can remove work whose result is unused or\nspecialize it more narrowly than the workload being modeled. Framework and loop\noverhead can also dominate operations that are too short. To reduce these risks:\n\n* Make values produced by measured work observable outside the measured\n  interval, for example by validating an aggregate derived from every result.\n  Passing them only through unused local computations is insufficient.\n* Perform enough operations in each sample to amortize fixed timer reads and\n  calls to `context.start()` and `context.end()`. If loop bookkeeping is material\n  relative to one operation, batch multiple operations per iteration and report\n  the total operation count.\n* Inspect raw `samples` for trends that indicate insufficient warmup or\n  optimization tiering, pauses consistent with garbage collection, and\n  multimodal distributions.\n* Validate surprising results with an independent benchmark shape that performs\n  the same intended work differently.\n\n`node:bench` does not force a particular optimization state or infer whether an\nengine eliminated work. Such controls and diagnostics are runtime-specific and\nheuristic, and do not replace validating the benchmark workload.","summary":"A statistically consistent result does not prove that a benchmark measured the intended work. An optimizing runtime can remove work whose result is unused or specialize it more narrowly than the workload being modeled. Framework and loop overhead can also dominate operations that are too short. To reduce these risks:","examples":[],"children":[]},{"kind":"section","id":"dynamic-sampling-and-variable-batches","name":"Dynamic sampling and variable batches","title":"Dynamic sampling and variable batches","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Calling `context.done()` during a measured sample completes the benchmark after\nthat sample. This allows a higher-level tool to treat `samples` as a maximum and\nimplement a dynamic sampling policy.\n\nThe number of operations can differ between samples. Summary statistics treat\neach sample's `rate` as one equally weighted observation. In particular,\n`summary.mean` is the arithmetic mean of the per-sample rates. It is not the\npooled throughput calculated as:\n\n```text\n1_000_000_000 * sum(sample.operations) / sum(sample.duration_ns)\n```\n\nThe two values can differ when sample durations vary because pooled throughput\nweights each per-sample rate by its duration. A higher-level tool that varies\nbatch sizes should choose the aggregation that matches its analysis. It can\ncalculate pooled throughput from the raw `samples`; operation counts should be\nsummed as `bigint` values because their total can exceed\n`Number.MAX_SAFE_INTEGER` even though each count cannot.","summary":"Calling `context.done()` during a measured sample completes the benchmark after that sample. This allows a higher-level tool to treat `samples` as a maximum and implement a dynamic sampling policy.","examples":[{"language":"text","displayName":null,"code":"1_000_000_000 * sum(sample.operations) / sum(sample.duration_ns)"}],"children":[]},{"kind":"section","id":"comparing-benchmark-results","name":"Comparing benchmark results","title":"Comparing benchmark results","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"`node:bench` does not designate a benchmark as a baseline or produce a pass/fail\ncomparison between runs. It exposes raw samples, stable benchmark identities,\nparameters, and tags so that comparison policy can remain in higher-level\ntools. A tool can use `benchId` to match the same declaration and parameters\nacross compatible source layouts, and use a tag or its own metadata to identify\na baseline.\n\nComparison tools should retain the raw sample rates and verify that execution\nplans and relevant environment details are comparable. The appropriate analysis\ndepends on the experimental design and distribution. For example, independent\nsamples might use Welch's t-test or a rank-based test, while observations that\nwere deliberately paired require paired analysis. Tools should also consider\neffect sizes, uncertainty, and correction when testing multiple benchmarks.\nThe general-purpose {Histogram} statistics in `node:perf_hooks` can support such\nanalysis, but the runner does not select a method or significance threshold.","summary":"`node:bench` does not designate a benchmark as a baseline or produce a pass/fail comparison between runs. It exposes raw samples, stable benchmark identities, parameters, and tags so that comparison policy can remain in higher-level tools. A tool can use `benchId` to match the same declaration and parameters across compatible source layouts, and use a tag or its own metadata to identify a baseline.","examples":[],"children":[]}]},{"kind":"section","id":"reusable-runners","name":"Reusable runners","title":"Reusable runners","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The module-level declaration functions use a shared runner and schedule it\nautomatically. Higher-level tools can create isolated, explicitly started\nrunners instead:\n\n```mjs\nimport { createRunner } from 'node:bench';\n\nconst runner = createRunner({ yieldBetweenSamples: false });\n\nrunner.bench('example', { samples: 100 }, (b) => {\n  const operations = chooseOperationCount();\n  b.start();\n  runOperations(operations);\n  const sample = b.end(operations);\n\n  if (hasEnoughData(sample)) b.done();\n});\n\nfor await (const record of runner.run()) {\n  // Consume structured benchmark records.\n}\n```\n\nEach runner has independent declarations, hooks, filtering, and output. Unlike\nthe module-level declarations, creating a benchmark on an explicit runner does\nnot schedule execution. This allows packages to collect declarations and start\nthem later. Calling the explicit runner's `run()` function prevents additional\ndeclarations and a second call to `run()` is an error.","summary":"The module-level declaration functions use a shared runner and schedule it automatically. Higher-level tools can create isolated, explicitly started runners instead:","examples":[{"language":"mjs","displayName":null,"code":"import { createRunner } from 'node:bench';\n\nconst runner = createRunner({ yieldBetweenSamples: false });\n\nrunner.bench('example', { samples: 100 }, (b) => {\n  const operations = chooseOperationCount();\n  b.start();\n  runOperations(operations);\n  const sample = b.end(operations);\n\n  if (hasEnoughData(sample)) b.done();\n});\n\nfor await (const record of runner.run()) {\n  // Consume structured benchmark records.\n}"}],"children":[]},{"kind":"section","id":"command-line-runner","name":"Command-line runner","title":"Command-line runner","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The `--bench` flag runs one or more explicit benchmark files or glob patterns:\n\n```console\nnode --experimental-bench --bench benchmark.mjs\nnode --experimental-bench --bench --bench-reporter=json 'benchmarks/**/*.js'\n```\n\nFiles are sorted and executed serially. The default\n`--bench-isolation=process` mode runs each file in a separate child process and\nemits one aggregate summary. Structured events are transferred to the parent\nwithout JSON conversion, preserving BigInt durations, errors, and parameter\nvalues. Child writes to stdout and stderr are emitted as diagnostic records so\nthey do not corrupt reporter output.\n\n`--bench-isolation=none` imports all files into the runner process. This mode\nhas lower startup overhead, but module, heap, and process state carry between\nfiles, and user writes share stdout and stderr with reporters.\n\nWorker-thread isolation is not a CLI mode. Each newly constructed {Worker} has a\nseparate V8 isolate, JavaScript heap, and event loop, typically with lower\nstartup cost than a child process. Reusing a worker preserves its module and heap\nstate. Workers also share libuv's process-wide thread pool and can share\nprocess-global native or addon state, so they do not provide the same boundary\nas process isolation.\n\nHigher-level tools can experiment with worker isolation by loading benchmark\ncode inside a worker, measuring there, transferring structured sample data, and\npassing it to [`context.record()`](#contextrecordsample). The reported `duration_ns` can exclude\nmessage transport when the worker captures both timestamps. Tools should\nidentify worker modules and workloads explicitly. They should not stringify\narbitrary functions or closures to move them between isolates, because closures\ncannot be reconstructed with their original lexical environment.\n\nBenchmark files passed to `--bench` should declare benchmarks but must not call\n`run()`. The CLI supports `--bench-name-pattern`, `--bench-samples`,\n`--bench-warmup`, `--bench-reporter`, and `--bench-reporter-destination`. See\nthe [command-line options documentation](cli.html#--bench) for details.\n\nPreload modules passed through `--require` or `--import` should not declare\nbenchmarks. Such declarations are not associated with an entry file and have\nan `entryFile` value of `null`. Their `fileRunId` identifies the runner or child\nexecution in which they occurred. With process isolation, a preload is evaluated\nand its declarations run once for every benchmark child process.","summary":"The `--bench` flag runs one or more explicit benchmark files or glob patterns:","examples":[{"language":"console","displayName":null,"code":"node --experimental-bench --bench benchmark.mjs\nnode --experimental-bench --bench --bench-reporter=json 'benchmarks/**/*.js'"}],"children":[]},{"kind":"section","id":"benchmark-reporters","name":"Benchmark reporters","title":"Benchmark reporters","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"The built-in reporters are available from the scheme-only\n`node:bench/reporters` module:\n\n```mjs\nimport { json, spec } from 'node:bench/reporters';\n```\n\n```cjs\nconst { json, spec } = require('node:bench/reporters');\n```\n\nReporter values can be passed directly to `stream.compose()`:\n\n```mjs\nimport { bench, run } from 'node:bench';\nimport { spec } from 'node:bench/reporters';\nimport process from 'node:process';\n\nbench('example', (b) => {\n  b.start();\n  doWork();\n  b.end(1);\n});\n\nrun().compose(spec).pipe(process.stdout);\n```\n\nThe `spec` reporter buffers results and outputs a concise table containing the\nsample count, mean rate, 95% confidence interval for the mean, median rate, and\nwarnings. A coefficient of variation above 5% is reported as `noisy`, and an\nabsolute skewness above 1 is reported as `skewed`. The exact human-readable\nformat is subject to change.\n\nThe `json` reporter emits every lifecycle record as newline-delimited JSON.\nBigInt values, including `duration_ns`, are encoded as decimal strings. Errors\nare represented using their `name`, `message`, `stack`, `code`, `cause`, and\n`errors` properties. As required by JSON, non-finite numbers are encoded as\n`null`.\n\nCustom reporters use the same composition contract. They can be transforms or\nfunctions accepted by `stream.compose()`. The composed readable can be piped to\nany writable destination:\n\n```mjs\nimport { run } from 'node:bench';\nimport process from 'node:process';\n\nasync function* names(source) {\n  for await (const { type, data } of source) {\n    if (type === 'bench:complete') {\n      yield `${data.name}\\n`;\n    }\n  }\n}\n\nrun().compose(names).pipe(process.stdout);\n```","summary":"The built-in reporters are available from the scheme-only `node:bench/reporters` module:","examples":[{"language":"mjs","displayName":null,"code":"import { json, spec } from 'node:bench/reporters';"},{"language":"cjs","displayName":null,"code":"const { json, spec } = require('node:bench/reporters');"},{"language":"mjs","displayName":null,"code":"import { bench, run } from 'node:bench';\nimport { spec } from 'node:bench/reporters';\nimport process from 'node:process';\n\nbench('example', (b) => {\n  b.start();\n  doWork();\n  b.end(1);\n});\n\nrun().compose(spec).pipe(process.stdout);"},{"language":"mjs","displayName":null,"code":"import { run } from 'node:bench';\nimport process from 'node:process';\n\nasync function* names(source) {\n  for await (const { type, data } of source) {\n    if (type === 'bench:complete') {\n      yield `${data.name}\\n`;\n    }\n  }\n}\n\nrun().compose(names).pipe(process.stdout);"}],"children":[]},{"kind":"method","id":"createrunneroptions","name":"createRunner","title":"`createRunner([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"yieldBetweenSamples","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Schedule an event loop turn between sample\ncallbacks. Disabling this also prevents timer-based abort signals from\nfiring between synchronous callbacks. Benchmark timeouts continue to be\nchecked against a monotonic deadline.","default":"true","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"An isolated benchmark runner with bound `after`, `afterEach`,\n`before`, `beforeEach`, `bench`, `describe`, `run`, and `suite` functions."}},"description":"Creates an explicitly started benchmark runner. Declarations made through one\nrunner do not interact with declarations made through another runner or through\nthe module-level functions. Call the returned `run()` function to start the\nrunner and obtain its {BenchmarksStream}.\n\nEach runner can be started once. Its `run()` function accepts the same options\nas the module-level [`run()`](#runoptions). `run({ yieldBetweenSamples })` overrides the\nvalue passed to `createRunner()`.","summary":"Creates an explicitly started benchmark runner. Declarations made through one runner do not interact with declarations made through another runner or through the module-level functions. Call the returned `run()` function to start the runner and obtain its {BenchmarksStream}.","examples":[],"children":[]},{"kind":"method","id":"benchname-options-fn","name":"bench","title":"`bench([name][, options], fn)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"name","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The benchmark name.","default":"The `name` property of `fn`, or `'<anonymous>'` when `fn` has no name","optional":true,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"diagnosticChannels","type":{"text":"Array","links":[{"name":"Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array","start":0,"end":5}]},"description":"String diagnostics channel names, deduplicated\nand inherited from containing suites by union. Symbol values in the array\nare silently ignored.","default":"[]","optional":true,"rest":false,"properties":[]},{"name":"only","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"When any benchmark or containing suite has `only` set,\nbenchmarks without `only` in their hierarchy are skipped.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"params","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"String, finite number, or boolean metadata identifying\nthis benchmark configuration. Parameter keys are sorted when constructing\nthe stable benchmark identity.","default":"An empty object","optional":true,"rest":false,"properties":[]},{"name":"samples","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The maximum number of measured callback invocations.\nMust be a positive 32-bit unsigned integer. The benchmark may finish earlier\nby calling `context.done()`.","default":"30","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"Allows aborting this benchmark.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"skip","type":{"text":"boolean | string","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":10,"end":16}]},"description":"If truthy, the benchmark is skipped. A string is\nincluded in the result as the skip reason.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"tags","type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Labels associated with the benchmark. Tags are\nlowercased, deduplicated, and inherited from containing suites by union.","default":"[]","optional":true,"rest":false,"properties":[]},{"name":"timeout","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of milliseconds after which the benchmark\nfails.","default":"Infinity","optional":true,"rest":false,"properties":[]},{"name":"warmup","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of unreported callback invocations before\nmeasured samples. Must be a 32-bit unsigned integer.","default":"0","optional":true,"rest":false,"properties":[]}]},{"name":"fn","type":{"text":"Function | AsyncFunction","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"AsyncFunction","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction","start":11,"end":24}]},"description":"The benchmark function. It receives a\n{BenchContext}.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfilled with the benchmark result after a top-level\nbenchmark finishes, or with `undefined` immediately when declared in a\nsuite."}},"description":"Warmup invocations use the same callback and timing contract as measured\nsamples, but their samples are discarded. An exception, rejection, timeout,\nabort, missing timing call, or duplicate timing call stops the current\nbenchmark. Later benchmarks continue to run.\n\nAfter a timeout or abort, the runner briefly waits for asynchronous benchmark\nwork to settle before continuing. If it remains pending, all later benchmarks\nthat were selected to run fail without running so that their measurements\ncannot overlap with that work.\n\nFor each warmup and measured callback, the runner subscribes to the configured\ndiagnostics channels. Each publication queues a context diagnostic whose\n`message` is `{ name, message }`, containing the string channel name and the\npublished message. Subscriptions are removed when the callback settles or is\naborted.\n\nA timeout or abort cannot interrupt synchronous JavaScript and does not forcibly\ncancel asynchronous work that ignores `context.signal`.\n\nThe `benchId` is based on the declaration source file, hierarchical suite and\nbenchmark names, and canonicalized parameters. It is stable for repeated runs\nfrom the same source location, but the embedded source value is not normalized\nacross checkout roots, module formats, operating systems, or path casing.\n\nExecution scope is represented separately. A `runId` identifies one logical\nrun, while `fileRunId` identifies a file runner or child execution within that\nrun. The `entryFile` field records which entry-file import caused a declaration\nand is `null` for declarations made by preload modules.\nThe same `benchId` can therefore occur under multiple `fileRunId` values when\nentry files use a shared declaration helper. Declaring the same `benchId` more\nthan once within one file execution scope reports an error rather than merging\nthe samples.","summary":"Warmup invocations use the same callback and timing contract as measured samples, but their samples are discarded. An exception, rejection, timeout, abort, missing timing call, or duplicate timing call stops the current benchmark. Later benchmarks continue to run.","examples":[],"children":[{"kind":"method","id":"benchskipname-options-fn","name":"skip","title":"`bench.skip([name][, options], fn)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"name","type":null,"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"options","type":null,"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"fn","type":null,"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Shorthand for `bench(name, { ...options, skip: true }, fn)`.","summary":"Shorthand for `bench(name, { ...options, skip: true }, fn)`.","examples":[],"children":[]},{"kind":"method","id":"benchonlyname-options-fn","name":"only","title":"`bench.only([name][, options], fn)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"name","type":null,"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"options","type":null,"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"fn","type":null,"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Shorthand for `bench(name, { ...options, only: true }, fn)`.","summary":"Shorthand for `bench(name, { ...options, only: true }, fn)`.","examples":[],"children":[]}]},{"kind":"method","id":"suitename-options-fn","name":"suite","title":"`suite([name][, options], fn)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"name","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"The suite name.","default":"The `name` property of `fn`, or `'<anonymous>'` when `fn` has no name","optional":true,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"diagnosticChannels","type":{"text":"Array","links":[{"name":"Array","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array","start":0,"end":5}]},"description":"String diagnostics channel names inherited by\nnested suites and benchmarks. Symbol values in the array are silently\nignored.","default":"[]","optional":true,"rest":false,"properties":[]},{"name":"only","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Selects all benchmarks nested in this suite.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"skip","type":{"text":"boolean | string","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7},{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":10,"end":16}]},"description":"Skips all benchmarks nested in this suite.","default":"false","optional":true,"rest":false,"properties":[]},{"name":"tags","type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Labels inherited by nested suites and benchmarks.","default":"[]","optional":true,"rest":false,"properties":[]}]},{"name":"fn","type":{"text":"Function | AsyncFunction","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"AsyncFunction","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction","start":11,"end":24}]},"description":"A function that declares nested suites,\nbenchmarks, and hooks.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":{"type":{"text":"Promise","links":[{"name":"Promise","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise","start":0,"end":7}]},"description":"Fulfilled when a top-level suite finishes, or with\n`undefined` immediately when declared in another suite."}},"description":"Suite functions run while declarations are collected. Promise-returning suite\nfunctions are awaited before benchmark execution begins.","summary":"Suite functions run while declarations are collected. Promise-returning suite functions are awaited before benchmark execution begins.","examples":[],"children":[]},{"kind":"method","id":"describename-options-fn","name":"describe","title":"`describe([name][, options], fn)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"name","type":null,"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"options","type":null,"description":"","default":null,"optional":true,"rest":false,"properties":[]},{"name":"fn","type":null,"description":"","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Alias for `suite()`.","summary":"Alias for `suite()`.","examples":[],"children":[]},{"kind":"method","id":"beforefn","name":"before","title":"`before(fn)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fn","type":{"text":"Function | AsyncFunction","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"AsyncFunction","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction","start":11,"end":24}]},"description":"The hook function.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Registers a hook that runs once before the benchmarks in the current suite.","summary":"Registers a hook that runs once before the benchmarks in the current suite.","examples":[],"children":[]},{"kind":"method","id":"afterfn","name":"after","title":"`after(fn)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fn","type":{"text":"Function | AsyncFunction","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"AsyncFunction","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction","start":11,"end":24}]},"description":"The hook function.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Registers a hook that runs once after the benchmarks in the current suite.","summary":"Registers a hook that runs once after the benchmarks in the current suite.","examples":[],"children":[]},{"kind":"method","id":"beforeeachfn","name":"beforeEach","title":"`beforeEach(fn)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fn","type":{"text":"Function | AsyncFunction","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"AsyncFunction","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction","start":11,"end":24}]},"description":"The hook function. It receives an object with\nthe benchmark's `name`, `params`, and `signal`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Registers a hook that runs once before each complete logical benchmark in the\ncurrent suite. It does not run before every sample. Per-sample setup belongs in\nthe benchmark function before `context.start()` or `context.record()`.","summary":"Registers a hook that runs once before each complete logical benchmark in the current suite. It does not run before every sample. Per-sample setup belongs in the benchmark function before `context.start()` or `context.record()`.","examples":[],"children":[]},{"kind":"method","id":"aftereachfn","name":"afterEach","title":"`afterEach(fn)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"fn","type":{"text":"Function | AsyncFunction","links":[{"name":"Function","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function","start":0,"end":8},{"name":"AsyncFunction","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction","start":11,"end":24}]},"description":"The hook function. It receives an object with\nthe benchmark's `name`, `params`, and `signal`.","default":null,"optional":false,"rest":false,"properties":[]}],"returns":null},"description":"Registers a hook that runs once after each complete logical benchmark in the\ncurrent suite. It does not run after every sample. Per-sample cleanup belongs\nin the benchmark function after `context.end()` or `context.record()`.","summary":"Registers a hook that runs once after each complete logical benchmark in the current suite. It does not run after every sample. Per-sample cleanup belongs in the benchmark function after `context.end()` or `context.record()`.","examples":[],"children":[]},{"kind":"method","id":"runoptions","name":"run","title":"`run([options])`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"namePattern","type":{"text":"string | RegExp","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"RegExp","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp","start":9,"end":15}]},"description":"Only runs benchmarks whose full hierarchical\nname matches the pattern. String values are interpreted as JavaScript\nregular expressions.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"samples","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Overrides the maximum number of measured callback\ninvocations for every benchmark. Must be a positive 32-bit unsigned integer.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"Allows aborting in-progress benchmark execution.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"warmup","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"Overrides the number of unreported warmup callback\ninvocations for every benchmark. Must be a 32-bit unsigned integer.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"yieldBetweenSamples","type":{"text":"boolean","links":[{"name":"boolean","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#boolean_type","start":0,"end":7}]},"description":"Schedule an event loop turn between sample\ncallbacks.","default":"`true`, or the value passed to `createRunner()` for an explicit runner","optional":true,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"BenchmarksStream","links":[]},"description":""}},"description":"Returns the object-mode event stream for the in-process benchmark run. Call\n`run()` during the same turn in which benchmarks are declared, before automatic\nexecution begins. Calling `run()` is optional when the returned stream is not\nneeded. An explicit runner created by `createRunner()` does not run\nautomatically, so its `run()` function may be called later.\n\n```mjs\nimport { bench, run } from 'node:bench';\n\nbench('example', { samples: 3 }, (b) => {\n  b.start();\n  doWork();\n  b.end(1);\n});\n\nfor await (const { type, data } of run()) {\n  if (type === 'bench:complete' && data.error === undefined) {\n    console.log(data.name, data.summary.mean);\n  }\n}\n```","summary":"Returns the object-mode event stream for the in-process benchmark run. Call `run()` during the same turn in which benchmarks are declared, before automatic execution begins. Calling `run()` is optional when the returned stream is not needed. An explicit runner created by `createRunner()` does not run automatically, so its `run()` function may be called later.","examples":[{"language":"mjs","displayName":null,"code":"import { bench, run } from 'node:bench';\n\nbench('example', { samples: 3 }, (b) => {\n  b.start();\n  doWork();\n  b.end(1);\n});\n\nfor await (const { type, data } of run()) {\n  if (type === 'bench:complete' && data.error === undefined) {\n    console.log(data.name, data.summary.mean);\n  }\n}"}],"children":[]},{"kind":"method","id":"runfilepath-options","name":"runFile","title":"`runFile(path[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"path","type":{"text":"string | Buffer | URL","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6},{"name":"Buffer","href":"buffer.html#class-buffer","start":9,"end":15},{"name":"URL","href":"url.html#the-whatwg-url-api","start":18,"end":21}]},"description":"The path of one benchmark module.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"env","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"The child process environment. Property values must be\nstrings or `undefined`. This replaces, rather than extends, the parent\nenvironment.","default":"A snapshot of `process.env`","optional":true,"rest":false,"properties":[]},{"name":"execArgv","type":{"text":"string[]","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Node.js command-line options for the child process.\nThis replaces, rather than extends, inherited options. Benchmark runner\noptions, positional arguments, and options that select another execution\nmode are not allowed.","default":"Compatible options inherited from the current process","optional":true,"rest":false,"properties":[]},{"name":"signal","type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"description":"Terminates the child process when aborted.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"BenchmarksStream","links":[]},"description":""}},"description":"Runs exactly one benchmark module in a fresh child process and returns its\nobject-mode event stream. A relative `path` is resolved from the current working\ndirectory when `runFile()` is called. `path` is not interpreted as a glob.\nUnless the signal is aborted or the stream is destroyed before startup, every\ncall uses a new child. Input discovery, ordering, concurrency, retries, and\nmulti-file scheduling remain the caller's responsibility.\n\nWhen the Permission Model is enabled, the caller must have file system read\naccess to `path` and permission to create child processes.\n\nRecords use advanced child process serialization, preserving supported\nstructured values such as `bigint` and errors. Child writes to stdout and stderr\nbecome `'bench:diagnostic'` records. A permission failure, module loading error,\nabnormal child exit, or cancellation also emits an error diagnostic and produces\na terminal `'bench:summary'` whose `success` property is `false`; these execution\nfailures do not error the stream. If module evaluation fails after declaring\nbenchmarks, those declarations still run before the unsuccessful summary.\n\n`env`, effective inherited options, and an explicitly provided `execArgv` are\ncopied when `runFile()` is called. The runner removes `NODE_OPTIONS`, replaces\nIPC-related environment variables, and sets its private child-context, run\nidentity, and file identity variables, overriding properties with those names\nin `env`. Pass child Node.js options through `execArgv`, not `NODE_OPTIONS`.\nStandard `child_process` environment propagation still applies, including\n`NODE_V8_COVERAGE`, permission-model options, and required z/OS variables.\nAborting `signal` before the child starts produces an `AbortError` diagnostic\nwithout spawning it. Aborting during execution sends `SIGTERM` to the child and\nescalates to `SIGKILL` if it does not exit. Destroying the returned stream\nfollows the same termination procedure.","summary":"Runs exactly one benchmark module in a fresh child process and returns its object-mode event stream. A relative `path` is resolved from the current working directory when `runFile()` is called. `path` is not interpreted as a glob. Unless the signal is aborted or the stream is destroyed before startup, every call uses a new child. Input discovery, ordering, concurrency, retries, and multi-file scheduling remain the caller's responsibility.","examples":[],"children":[]},{"kind":"class","id":"class-benchcontext","name":"BenchContext","title":"Class: `BenchContext`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"An instance of `BenchContext` is passed to every benchmark invocation. A new\ninstance is created for every warmup and measured sample.","summary":"An instance of `BenchContext` is passed to every benchmark invocation. A new instance is created for every warmup and measured sample.","examples":[],"children":[{"kind":"property","id":"contextindex","name":"index","title":"`context.index`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"default":null,"description":"The zero-based invocation index within the current `context.phase`. Warmup and\nmeasured samples have separate index sequences.","summary":"The zero-based invocation index within the current `context.phase`. Warmup and measured samples have separate index sequences.","examples":[],"children":[]},{"kind":"property","id":"contextname","name":"name","title":"`context.name`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The benchmark name.","summary":"The benchmark name.","examples":[],"children":[]},{"kind":"property","id":"contextparams","name":"params","title":"`context.params`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"default":null,"description":"The benchmark's canonicalized parameter metadata.","summary":"The benchmark's canonicalized parameter metadata.","examples":[],"children":[]},{"kind":"property","id":"contextphase","name":"phase","title":"`context.phase`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"default":null,"description":"The current sample phase. It is `'warmup'` for an unreported warmup invocation\nand `'measurement'` for a measured invocation.","summary":"The current sample phase. It is `'warmup'` for an unreported warmup invocation and `'measurement'` for a measured invocation.","examples":[],"children":[]},{"kind":"property","id":"contextsignal","name":"signal","title":"`context.signal`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"type":{"text":"AbortSignal","links":[{"name":"AbortSignal","href":"globals.html#class-abortsignal","start":0,"end":11}]},"default":null,"description":"An abort signal that is triggered when the benchmark is aborted, times out, or\nfinishes.","summary":"An abort signal that is triggered when the benchmark is aborted, times out, or finishes.","examples":[],"children":[]},{"kind":"method","id":"contextstart","name":"start","title":"`context.start()`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Starts the measured region using `process.hrtime.bigint()`. Calling `start()`\nmore than once is an error.","summary":"Starts the measured region using `process.hrtime.bigint()`. Calling `start()` more than once is an error.","examples":[],"children":[]},{"kind":"method","id":"contextendoperations-options","name":"end","title":"`context.end(operations[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"operations","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of completed operations. Must be a positive\nsafe integer.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"detail","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"Additional structured-cloneable sample data. With CLI process\nisolation, it must also be supported by advanced child process\nserialization.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"The sample's `operations`, `duration_ns`, computed `rate`,\nand optional cloned `detail`."}},"description":"Ends the measured region. The end timestamp is captured before `operations` is\nvalidated. Calling `end()` before `start()`, calling it more than once, or\nrecording a zero-duration sample is an error. When provided, `detail` is cloned\nafter the end timestamp is captured, so cloning time is outside the measured\nregion.","summary":"Ends the measured region. The end timestamp is captured before `operations` is validated. Calling `end()` before `start()`, calling it more than once, or recording a zero-duration sample is an error. When provided, `detail` is cloned after the end timestamp is captured, so cloning time is outside the measured region.","examples":[],"children":[]},{"kind":"method","id":"contextrecordsample","name":"record","title":"`context.record(sample)`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"sample","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":false,"rest":false,"properties":[{"name":"operations","type":{"text":"number","links":[{"name":"number","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#number_type","start":0,"end":6}]},"description":"The number of completed operations. Must be a positive\nsafe integer.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"duration_ns","type":{"text":"bigint","links":[{"name":"bigint","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#bigint_type","start":0,"end":6}]},"description":"An externally measured positive duration in\nnanoseconds no greater than `Number.MAX_SAFE_INTEGER`.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"detail","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"Additional structured-cloneable sample data. With CLI process\nisolation, it must also be supported by advanced child process\nserialization.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"The normalized sample, including its computed `rate` and\noptional cloned `detail`."}},"description":"Records a measurement made by another clock or execution environment. This is\nuseful when a higher-level tool measures work in a worker and needs to exclude\nmessage transport from the duration. `record()` is mutually exclusive with\n`start()` and `end()` within one callback and must be called exactly once.","summary":"Records a measurement made by another clock or execution environment. This is useful when a higher-level tool measures work in a worker and needs to exclude message transport from the duration. `record()` is mutually exclusive with `start()` and `end()` within one callback and must be called exactly once.","examples":[],"children":[]},{"kind":"method","id":"contextdiagnosticmessage-options","name":"diagnostic","title":"`context.diagnostic(message[, options])`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[{"name":"message","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"A structured-cloneable diagnostic value. With CLI process\nisolation, it must also be supported by advanced child process serialization.","default":null,"optional":false,"rest":false,"properties":[]},{"name":"options","type":{"text":"Object","links":[{"name":"Object","href":"https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object","start":0,"end":6}]},"description":"","default":null,"optional":true,"rest":false,"properties":[{"name":"level","type":{"text":"string","links":[{"name":"string","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#string_type","start":0,"end":6}]},"description":"Either `'info'` or `'warning'`.","default":"'info'","optional":true,"rest":false,"properties":[]},{"name":"detail","type":{"text":"any","links":[{"name":"any","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Data_types","start":0,"end":3}]},"description":"Additional structured-cloneable diagnostic data. With CLI\nprocess isolation, it must also be supported by advanced child process\nserialization.","default":null,"optional":false,"rest":false,"properties":[]}]}],"returns":{"type":{"text":"undefined","links":[{"name":"undefined","href":"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#undefined_type","start":0,"end":9}]},"description":""}},"description":"Queues a diagnostic associated with the current benchmark, phase, and sample\nindex. Multiple diagnostics preserve call order. They are emitted after the\nsample callback settles and before that sample's `'bench:sample'` event. Warmup\ndiagnostics are emitted even though warmup samples are not. Diagnostics queued\nbefore a callback failure are emitted before the failed `'bench:complete'`\nevent and do not themselves cause the benchmark to fail. If a timeout or abort\nwins before the callback settles, queued diagnostics might not be emitted.\n\nThe message and detail are cloned synchronously. Options are also validated\nsynchronously. Calling `diagnostic()` between `context.start()` and\n`context.end()` therefore includes that work in the measured duration. Invalid\narguments or an uncloneable message or detail violate the sample contract.","summary":"Queues a diagnostic associated with the current benchmark, phase, and sample index. Multiple diagnostics preserve call order. They are emitted after the sample callback settles and before that sample's `'bench:sample'` event. Warmup diagnostics are emitted even though warmup samples are not. Diagnostics queued before a callback failure are emitted before the failed `'bench:complete'` event and do not themselves cause the benchmark to fail. If a timeout or abort wins before the callback settles, queued diagnostics might not be emitted.","examples":[],"children":[]},{"kind":"method","id":"contextdone","name":"done","title":"`context.done()`","scope":"module","overloadOf":null,"stability":null,"added":["v26.9.0"],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"signature":{"parameters":[],"returns":null},"description":"Requests successful benchmark completion after the current measured sample.\nThe callback must still call either `start()` and `end()`, or `record()`.\nCalling `done()` during a warmup invocation is an error. The configured\n`samples` value remains the maximum number of measured invocations if `done()`\nis not called.","summary":"Requests successful benchmark completion after the current measured sample. The callback must still call either `start()` and `end()`, or `record()`. Calling `done()` during a warmup invocation is an error. The configured `samples` value remains the maximum number of measured invocations if `done()` is not called.","examples":[],"children":[]}]},{"kind":"class","id":"class-benchmarksstream","name":"BenchmarksStream","title":"Class: `BenchmarksStream`","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"extends":null,"description":"`BenchmarksStream` is an object-mode {stream.Readable}. Each lifecycle record is\nboth emitted as a named event and made available on the stream as\n`{ type, data }`.\n\nThe events are emitted in execution order:\n\n* `'bench:plan'`\n* `'bench:start'`\n* `'bench:sample'`\n* `'bench:complete'`\n* `'bench:diagnostic'`\n* `'bench:summary'`\n\nNamed event payloads, readable records, and benchmark completion values are\nindependent snapshots. Mutating a value received through one delivery mechanism\ndoes not change values received through the others. As with other\n{EventEmitter} events, multiple listeners for the same named event receive the\nsame event payload. Memory referenced through a {SharedArrayBuffer} remains\nshared, following structured clone semantics.\n\nOnce a consumer starts reading, the runner honors the stream's object-mode\nhigh-water mark and waits between records when the consumer is slower than the\nproducer. These waits occur after sample timing has ended, and records are not\ndropped. Snapshot creation and delivery waits are excluded from benchmark\ntimeout accounting. Before readable consumption starts, records accumulate in\nthe standard readable buffer and are included in `readableLength`. This keeps an\nunread stream and a consumer using only named events from deadlocking, but the\nbuffer can grow without bound. A named-event-only consumer that does not need\nreadable records should call `stream.resume()` to discard them. Destroying the\nstream stops readable delivery but does not cancel benchmark execution, so\nbenchmark completion promises still settle. Automatically scheduled\nmodule-level runs drain their stream internally.\n\nWith process isolation, each record sent by a child is acknowledged only after\nthe parent has accepted it. A child sends no additional record until it receives\nthat acknowledgement, bounding the IPC relay when a reporter is slow.\n\nEvery benchmark-scoped event contains `runId`, `fileRunId`, `entryFile`,\n`benchId`, `parentId`, and `namePath`. `runId` and `fileRunId` are opaque and\nchange between runs. `entryFile` identifies the top-level benchmark file whose\nloading caused the declaration, while `file` identifies the source location of\nthe declaration itself. `parentId` is based on the containing suite's source\nfile and hierarchical name path.\n\nAfter asynchronous suite declarations settle, an in-process runner emits one\n`'bench:plan'` event for every benchmark it collected, in declaration order.\nAll plans from that runner are emitted before its suite hooks or benchmark\ncallbacks run. With process isolation, files run in separate children, so plans\nfor a later file are emitted after an earlier child has completed. With no\nisolation, all files share one runner and their plans are emitted before any\nbenchmark executes. Plan data contains the benchmark-scoped identity, location,\ntags, and parameters described in [benchmark result](#benchmark-result), together with:\n\n* `diagnosticChannels` {string[]} The inherited string channel names\n  subscribed to during each callback.\n* `samples` {number} The effective maximum number of measured callback\n  invocations after run-level overrides.\n* `warmup` {number} The effective number of unreported warmup callback\n  invocations after run-level overrides.\n* `timeout` {number | null} The timeout in milliseconds, or `null` when no timeout\n  is configured.\n* `yieldBetweenSamples` {boolean} Whether an event loop turn is scheduled between\n  sample callbacks.\n* `selected` {boolean} Whether the benchmark is eligible to run after applying\n  `skip`, `only`, and `namePattern` selection. Execution can still be prevented\n  by a duplicate declaration, suite build, hook, abort, or other runtime failure.\n* `skip` {boolean | string} When `selected` is `false`, the explicit skip value or\n  the selection reason, such as `'only'` or `'name pattern'`.\n\nThe plan contains execution settings known to the runner. Runtime version,\noperating system, processor, and other environment metadata are intentionally\nleft for reporters and higher-level tools to collect.\n\n`'bench:complete'` data contains a [benchmark result](#benchmark-result). A failed result has an\nadditional `error` property and may contain samples recorded before the error.\nA skipped result has an additional `skip` property and an empty `samples`\narray. `'bench:diagnostic'` reports loading, suite, and hook errors as well as\npublic context diagnostics. A context diagnostic contains the benchmark-scoped\nidentity fields, `phase`, `index`, `message`, `level`, source location, and\noptional `detail`. `'bench:summary'` contains overall `runId`, `fileRunId`,\n`entryFile`, `success`, `counts`, `duration_ns`, and `file` properties.\n`fileRunId`, `entryFile`, and `file` are {string | null}; they are `null` when the\nsummary aggregates multiple files.","summary":"`BenchmarksStream` is an object-mode {stream.Readable}. Each lifecycle record is both emitted as a named event and made available on the stream as `{ type, data }`.","examples":[],"children":[]},{"kind":"section","id":"sample-result","name":"Sample result","title":"Sample result","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"Each measured sample has the following properties:\n\n* `operations` {number} The positive operation count passed to\n  `context.end()` or `context.record()`.\n* `duration_ns` {bigint} The measured duration in nanoseconds.\n* `rate` {number} Operations per second.\n* `detail` {any} The optional cloned sample detail.","summary":"Each measured sample has the following properties:","examples":[],"children":[]},{"kind":"section","id":"benchmark-result","name":"Benchmark result","title":"Benchmark result","scope":"module","overloadOf":null,"stability":null,"added":[],"deprecated":[],"removed":[],"napiVersion":[],"changes":[],"description":"A completed benchmark result contains:\n\n* `runId` {string} The opaque logical run identity.\n* `fileRunId` {string} The opaque file runner or child execution identity.\n* `entryFile` {string | null} The top-level file that caused this declaration.\n* `benchId` {string} The stable declaration identity within the same source\n  layout.\n* `parentId` {string | null} The stable containing suite identity.\n* `name` {string} The benchmark name.\n* `namePath` {string[]} The hierarchical suite and benchmark names.\n* `file` {string} The declaration source file.\n* `line` {number} The source line.\n* `column` {number} The source column.\n* `tags` {string[]} The inherited canonical tags.\n* `params` {Object} The canonical parameter metadata.\n* `samples` {Object[]} The exact measured samples in measurement invocation\n  order.\n* `summary` {Object}\n  * `mean` {number} The equally weighted arithmetic mean of per-sample rates,\n    not pooled throughput across all operations and durations.\n  * `median` {number} The median per-sample rate.\n  * `min` {number} The minimum per-sample rate.\n  * `max` {number} The maximum per-sample rate.\n  * `stddev` {number} The population standard deviation of rates.\n  * `coefficientOfVariation` {number} `stddev / mean`.\n  * `confidenceInterval` {Object} The 95% Student's t confidence interval for\n    the mean rate, with `lower` and `upper` properties.\n  * `medianConfidenceInterval` {Object} The 95% nonparametric confidence\n    interval for the median rate, with `lower` and `upper` properties.\n  * `skewness` {number} The skewness of the scaled rate histogram.","summary":"A completed benchmark result contains:","examples":[],"children":[]}]}