mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 23:43:09 +01:00
15720fa25a
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: https://github.com/nodejs/node/pull/5177 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
34 lines
593 B
JavaScript
34 lines
593 B
JavaScript
'use strict';
|
|
var common = require('../common.js');
|
|
var assert = require('assert');
|
|
|
|
const primValues = {
|
|
'null': null,
|
|
'undefined': undefined,
|
|
'string': 'a',
|
|
'number': 1,
|
|
'boolean': true,
|
|
'object': { 0: 'a' },
|
|
'array': [1, 2, 3],
|
|
'new-array': new Array([1, 2, 3])
|
|
};
|
|
|
|
var bench = common.createBenchmark(main, {
|
|
prim: Object.keys(primValues),
|
|
n: [1e5]
|
|
});
|
|
|
|
function main(conf) {
|
|
var prim = primValues[conf.prim];
|
|
var n = +conf.n;
|
|
var x;
|
|
|
|
bench.start();
|
|
|
|
for (x = 0; x < n; x++) {
|
|
assert.deepEqual(new Array([prim]), new Array([prim]));
|
|
}
|
|
|
|
bench.end(n);
|
|
}
|