Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

object[key] access performance drop since 0.12 #25614

Closed
yamsellem opened this issue Jul 2, 2015 · 1 comment
Closed

object[key] access performance drop since 0.12 #25614

yamsellem opened this issue Jul 2, 2015 · 1 comment

Comments

@yamsellem
Copy link

We've found a performance drop in our production code when migrating to node 0.12.
Here is a benchmark that reproduces it:

var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;

var filter = function(obj) {
    obj['property'];
};

var filterOn = function(obj, value) {
    obj[value];
};

suite
.add('Filter#fixed', function() {
    filter({property: 2});
})
.add('Filter#on', function() {
    filterOn({property: 2}, 'property');
})
.on('cycle', function(event) {
    console.log(String(event.target));
})
.run({ 'async': true });

On node 0.10.24

Filter#fixed x 64,682,540 ops/sec ±1.70% (86 runs sampled)
Filter#on x 57,602,016 ops/sec ±2.02% (80 runs sampled)

On node 0.12.5

Filter#fixed x 95,081,906 ops/sec ±1.68% (94 runs sampled)
Filter#on x 38,661,204 ops/sec ±2.43% (80 runs sampled)

Whereas node 0.12 is way faster on a 'static' object's attribute access, is seems slower when using a variable to access an attribute value.

This may be nothing, and may be negligible regarding the overall performance.
This may be relative to the issue #25501

@a0viedo
Copy link
Member

a0viedo commented Aug 20, 2015

I would bet this is V8 credit. I run some tests in io.js V3 and the performance drop seems to improve. Could you re-run your suite in io.js latest?

@Trott Trott closed this as completed Apr 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants