Skip to content

Commit 98bbd2e

Browse files
SeokhunEomaduh95
authored andcommitted
benchmark: allow boolean option values
Change createBenchmark to also accept booleans. PR-URL: #60129 Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
1 parent c4a9282 commit 98bbd2e

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

benchmark/common.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,9 @@ class Benchmark {
115115
const [, key, value] = match;
116116
if (configs[key] !== undefined) {
117117
cliOptions[key] ||= [];
118-
cliOptions[key].push(
119-
// Infer the type from the config object and parse accordingly
120-
typeof configs[key][0] === 'number' ? +value : value,
121-
);
118+
const configType = typeof configs[key][0];
119+
const configValue = configType === 'number' ? +value : configType === 'boolean' ? value === 'true' : value;
120+
cliOptions[key].push(configValue);
122121
} else {
123122
extraOptions[key] = value;
124123
}
@@ -138,7 +137,7 @@ class Benchmark {
138137
const values = options[key];
139138

140139
for (const value of values) {
141-
if (typeof value !== 'number' && typeof value !== 'string') {
140+
if (typeof value !== 'number' && typeof value !== 'string' && typeof value !== 'boolean') {
142141
throw new TypeError(
143142
`configuration "${key}" had type ${typeof value}`);
144143
}

0 commit comments

Comments
 (0)