-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
Closed
Labels
performanceIssues and PRs related to the performance of Node.js.Issues and PRs related to the performance of Node.js.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.
Description
- Versions: Tested in Node 5.9, 5.11, 6.0, 6.4, 6.5, 6.6, 6.7
- Platform: Linux (Kubuntu 16.04)
- Subsystem: N/A / Not sure?
It appears that joining together raw strings has some performance regressions in the 6.x line. I first noticed this when evaluating the classnames
library for a project and running its benchmarks as my coworker on 5.9.0 was getting roughly double the speed I was getting with 6.6.0. But I've extracted the meat of the issue into a small sample test.
When I asked on #node-dev
about this I was suggested to test 5.11 -> 6.0 as well as 6.4 -> 6.5 as those were major bumps for V8 versions.
The test requires benchmark.js
, if someone could point me as to how to do a raw node benchmark this would be appreciated.
function join_strings() {
var result = [];
for (var i = 0; i < arguments.length; i++) {
if (typeof arguments[i] === 'string' || typeof arguments[i] === 'number') {
result.push(arguments[i]);
}
}
return result.join(' ');
}
// Test case.
var testVal = ['one', 'two', 'three'];
var benchmark = require('benchmark');
var suite = new benchmark.Suite();
suite.add('test-join-str', function() {
join_strings.apply(null, testVal);
});
suite.on('cycle', function(event) {
console.log('Result:', String(event.target));
});
suite.run();
Results of tests
- Node 5.11.0 -
node min-string-test.js Result: test-join-str x 8,037,676 ops/sec ±1.05% (92 runs sampled)
- Node 6.0.0 -
node min-string-test.js Result: test-join-str x 1,985,858 ops/sec ±1.71% (90 runs sampled)
- Node 6.4.0 -
node min-string-test.js Result: test-join-str x 2,120,274 ops/sec ±0.93% (94 runs sampled)
- Node 6.5.0 -
node min-string-test.js Result: test-join-str x 3,738,101 ops/sec ±0.92% (92 runs sampled)
- Node 6.6.0 -
node min-string-test.js Result: test-join-str x 3,710,874 ops/sec ±1.45% (92 runs sampled)
- Node 6.7.0 -
node min-string-test.js Result: test-join-str x 3,703,040 ops/sec ±0.98% (93 runs sampled)
Metadata
Metadata
Assignees
Labels
performanceIssues and PRs related to the performance of Node.js.Issues and PRs related to the performance of Node.js.v8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.