mirror of
https://github.com/nodejs/node.git
synced 2024-11-30 15:30:56 +01:00
63786227cc
assert.deepEqual: when actual and expected are typed arrays, wrap them in a new Buffer each to increase performance significantly. PR-URL: https://github.com/nodejs/node/pull/4330 Fixes: https://github.com/nodejs/node/issues/4294 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
38 lines
653 B
JavaScript
38 lines
653 B
JavaScript
'use strict';
|
|
var common = require('../common.js');
|
|
var assert = require('assert');
|
|
var bench = common.createBenchmark(main, {
|
|
prim: [
|
|
null,
|
|
undefined,
|
|
'a',
|
|
1,
|
|
true,
|
|
{0: 'a'},
|
|
[1, 2, 3],
|
|
new Array([1, 2, 3])
|
|
],
|
|
n: [25]
|
|
});
|
|
|
|
function main(conf) {
|
|
var prim = conf.prim;
|
|
var n = +conf.n;
|
|
var primArray;
|
|
var primArrayCompare;
|
|
var x;
|
|
|
|
primArray = new Array();
|
|
primArrayCompare = new Array();
|
|
for (x = 0; x < (1e5); x++) {
|
|
primArray.push(prim);
|
|
primArrayCompare.push(prim);
|
|
}
|
|
|
|
bench.start();
|
|
for (x = 0; x < n; x++) {
|
|
assert.deepEqual(primArray, primArrayCompare);
|
|
}
|
|
bench.end(n);
|
|
}
|