Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ class Benchmark {
const [, key, value] = match;
if (configs[key] !== undefined) {
cliOptions[key] ||= [];
cliOptions[key].push(
// Infer the type from the config object and parse accordingly
typeof configs[key][0] === 'number' ? +value : value,
);
const configType = typeof configs[key][0];
const configValue = configType === 'number' ? +value : configType === 'boolean' ? value === 'true' : value;
cliOptions[key].push(configValue);
} else {
extraOptions[key] = value;
}
Expand All @@ -140,7 +139,7 @@ class Benchmark {
const values = options[key];

for (const value of values) {
if (typeof value !== 'number' && typeof value !== 'string') {
if (typeof value !== 'number' && typeof value !== 'string' && typeof value !== 'boolean') {
throw new TypeError(
`configuration "${key}" had type ${typeof value}`);
}
Expand Down
3 changes: 1 addition & 2 deletions benchmark/crypto/randomUUID.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ const { randomUUID } = require('crypto');

const bench = common.createBenchmark(main, {
n: [1e7],
disableEntropyCache: [0, 1],
disableEntropyCache: [false, true],
});

function main({ n, disableEntropyCache }) {
disableEntropyCache = !!disableEntropyCache;
bench.start();
for (let i = 0; i < n; ++i)
randomUUID({ disableEntropyCache });
Expand Down
4 changes: 2 additions & 2 deletions benchmark/util/deprecate.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const assert = require('assert');

const bench = common.createBenchmark(main, {
n: [1e5],
modifyPrototype: [1, 0],
modifyPrototype: [true, false],
emitWarningSync: [1, 0],
}, {
flags: ['--expose-internals'],
Expand All @@ -23,7 +23,7 @@ function main({ n, modifyPrototype, emitWarningSync }) {
'This function is deprecated',
'DEP0000',
emitWarningSync,
!!modifyPrototype,
modifyPrototype,
);

let sum = 0;
Expand Down
40 changes: 22 additions & 18 deletions doc/contributing/writing-and-running-benchmarks.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,27 @@

## Table of contents

* [Prerequisites](#prerequisites)
* [HTTP benchmark requirements](#http-benchmark-requirements)
* [HTTPS benchmark requirements](#https-benchmark-requirements)
* [HTTP/2 benchmark requirements](#http2-benchmark-requirements)
* [Benchmark analysis requirements](#benchmark-analysis-requirements)
* [Running benchmarks](#running-benchmarks)
* [Running individual benchmarks](#running-individual-benchmarks)
* [Calibrating the number of iterations with calibrate-n.js](#calibrating-the-number-of-iterations-with-calibrate-njs)
* [Running all benchmarks](#running-all-benchmarks)
* [Specifying CPU Cores for Benchmarks with run.js](#specifying-cpu-cores-for-benchmarks-with-runjs)
* [Filtering benchmarks](#filtering-benchmarks)
* [Comparing Node.js versions](#comparing-nodejs-versions)
* [Comparing parameters](#comparing-parameters)
* [Running benchmarks on the CI](#running-benchmarks-on-the-ci)
* [Creating a benchmark](#creating-a-benchmark)
* [Basics of a benchmark](#basics-of-a-benchmark)
* [Creating an HTTP benchmark](#creating-an-http-benchmark)
* [How to write and run benchmarks in Node.js core](#how-to-write-and-run-benchmarks-in-nodejs-core)
* [Table of contents](#table-of-contents)
* [Prerequisites](#prerequisites)
* [HTTP benchmark requirements](#http-benchmark-requirements)
* [HTTPS benchmark requirements](#https-benchmark-requirements)
* [HTTP/2 benchmark requirements](#http2-benchmark-requirements)
* [Benchmark analysis requirements](#benchmark-analysis-requirements)
* [Running benchmarks](#running-benchmarks)
* [Setting CPU Frequency scaling governor to "performance"](#setting-cpu-frequency-scaling-governor-to-performance)
* [Running individual benchmarks](#running-individual-benchmarks)
* [Calibrating the number of iterations with calibrate-n.js](#calibrating-the-number-of-iterations-with-calibrate-njs)
* [Running all benchmarks](#running-all-benchmarks)
* [Specifying CPU Cores for Benchmarks with run.js](#specifying-cpu-cores-for-benchmarks-with-runjs)
* [Filtering benchmarks](#filtering-benchmarks)
* [Grouping benchmarks](#grouping-benchmarks)
* [Comparing Node.js versions](#comparing-nodejs-versions)
* [Comparing parameters](#comparing-parameters)
* [Running benchmarks on the CI](#running-benchmarks-on-the-ci)
* [Creating a benchmark](#creating-a-benchmark)
* [Basics of a benchmark](#basics-of-a-benchmark)
* [Creating an HTTP benchmark](#creating-an-http-benchmark)

## Prerequisites

Expand Down Expand Up @@ -562,7 +566,7 @@ The arguments of `createBenchmark` are:
* `configs` {Object} The benchmark parameters. `createBenchmark` will run all
possible combinations of these parameters, unless specified otherwise.
Each configuration is a property with an array of possible values.
The configuration values can only be strings or numbers.
The configuration values can be strings, numbers, or booleans.
* `options` {Object} The benchmark options. Supported options:
* `flags` {Array} Contains node-specific command line flags to pass to
the child process.
Expand Down
Loading