mercredi 28 janvier 2015

slow function call in V8 when using the same key for the functions in different objects

Maybe not the call slow but rather the lookup, i'm not sure, but here is an example:



var foo = {};
foo.fn = function() {};

var bar = {};
bar.fn = function() {};

console.time('t');

for (var i = 0; i < 100000000; i++) {
foo.fn();
}

console.timeEnd('t');


Tested on win8.1



  • firefox 35.01: ~240ms

  • chrome 40.0.2214.93 (V8 3.30.33.15): ~760ms

  • msie 11: 34 sec

  • nodejs 0.10.21 (V8 3.14.5.9): ~100ms

  • iojs 1.0.4 (V8 4.1.0.12): ~760ms


Now here is the interesting part, if i change bar.fn to bar.somethingelse:



  • chrome 40.0.2214.93 (V8 3.30.33.15): ~100ms

  • nodejs 0.10.21 (V8 3.14.5.9): ~100ms

  • iojs 1.0.4 (V8 4.1.0.12): ~100ms


Something went wrong in v8 lately? What causes this?


Aucun commentaire:

Enregistrer un commentaire