Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 15720fa

Browse filesBrowse files
AndreasMadsenrvagg
authored andcommitted
benchmark: fix configuation parameters
The benchmark runner spawns new processes for each configuration. The specific configuration is transfered by process.argv. This means that the values have to be parsed. As of right now only numbers and strings are parsed correctly. However other values such as objects where used. This fixes the benchmarks that used non-string/number values and prevents future issues by asserting the type. PR-URL: #5177 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent f6c505d commit 15720fa
Copy full SHA for 15720fa

File tree

Expand file treeCollapse file tree

6 files changed

+36
-26
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

6 files changed

+36
-26
lines changed
Open diff view settings
Collapse file

‎benchmark/assert/deepequal-prims-and-objs-big-array.js‎

Copy file name to clipboardExpand all lines: benchmark/assert/deepequal-prims-and-objs-big-array.js
+14-11Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
'use strict';
22
var common = require('../common.js');
33
var assert = require('assert');
4+
5+
const primValues = {
6+
'null': null,
7+
'undefined': undefined,
8+
'string': 'a',
9+
'number': 1,
10+
'boolean': true,
11+
'object': { 0: 'a' },
12+
'array': [1, 2, 3],
13+
'new-array': new Array([1, 2, 3])
14+
};
15+
416
var bench = common.createBenchmark(main, {
5-
prim: [
6-
null,
7-
undefined,
8-
'a',
9-
1,
10-
true,
11-
{0: 'a'},
12-
[1, 2, 3],
13-
new Array([1, 2, 3])
14-
],
17+
prim: Object.keys(primValues),
1518
n: [25]
1619
});
1720

1821
function main(conf) {
19-
var prim = conf.prim;
22+
var prim = primValues[conf.prim];
2023
var n = +conf.n;
2124
var primArray;
2225
var primArrayCompare;
Collapse file

‎benchmark/assert/deepequal-prims-and-objs-big-loop.js‎

Copy file name to clipboardExpand all lines: benchmark/assert/deepequal-prims-and-objs-big-loop.js
+14-11Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
'use strict';
22
var common = require('../common.js');
33
var assert = require('assert');
4+
5+
const primValues = {
6+
'null': null,
7+
'undefined': undefined,
8+
'string': 'a',
9+
'number': 1,
10+
'boolean': true,
11+
'object': { 0: 'a' },
12+
'array': [1, 2, 3],
13+
'new-array': new Array([1, 2, 3])
14+
};
15+
416
var bench = common.createBenchmark(main, {
5-
prim: [
6-
null,
7-
undefined,
8-
'a',
9-
1,
10-
true,
11-
{0: 'a'},
12-
[1, 2, 3],
13-
new Array([1, 2, 3])
14-
],
17+
prim: Object.keys(primValues),
1518
n: [1e5]
1619
});
1720

1821
function main(conf) {
19-
var prim = conf.prim;
22+
var prim = primValues[conf.prim];
2023
var n = +conf.n;
2124
var x;
2225

Collapse file

‎benchmark/buffers/buffer-read.js‎

Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-read.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
var common = require('../common.js');
33

44
var bench = common.createBenchmark(main, {
5-
noAssert: [false, true],
5+
noAssert: ['false', 'true'],
66
buffer: ['fast', 'slow'],
77
type: ['UInt8', 'UInt16LE', 'UInt16BE',
88
'UInt32LE', 'UInt32BE',
Collapse file

‎benchmark/buffers/buffer-tostring.js‎

Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-tostring.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
const common = require('../common.js');
44

55
const bench = common.createBenchmark(main, {
6-
arg: [true, false],
6+
arg: ['true', 'false'],
77
len: [0, 1, 64, 1024],
88
n: [1e7]
99
});
1010

1111
function main(conf) {
12-
const arg = conf.arg;
12+
const arg = conf.arg === 'true';
1313
const len = conf.len | 0;
1414
const n = conf.n | 0;
1515
const buf = Buffer(len).fill(42);
Collapse file

‎benchmark/buffers/buffer-write.js‎

Copy file name to clipboardExpand all lines: benchmark/buffers/buffer-write.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
var common = require('../common.js');
33
var bench = common.createBenchmark(main, {
4-
noAssert: [false, true],
4+
noAssert: ['false', 'true'],
55
buffer: ['fast', 'slow'],
66
type: ['UInt8', 'UInt16LE', 'UInt16BE',
77
'UInt32LE', 'UInt32BE',
Collapse file

‎benchmark/common.js‎

Copy file name to clipboardExpand all lines: benchmark/common.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,10 @@ Benchmark.prototype._run = function() {
154154
var j = 0;
155155
set.forEach(function(s) {
156156
vals.forEach(function(val) {
157+
if (typeof val !== 'number' && typeof val !== 'string') {
158+
throw new TypeError(`configuration "${key}" had type ${typeof val}`);
159+
}
160+
157161
newSet[j++] = s.concat(key + '=' + val);
158162
});
159163
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.