In the process of developing a widget-portal using V8 JavaScript
engine and node.js, I decided to try some small performance benchmarks
to understand the different performance implications of using certain
"patterns". Overall the performance is incredible, V8 is really a
great engine.
One thing however I don't understand is why sometimes accessing object
properties is slower and sometimes it is very fast. For example in the
following code snippet the differences are big (using V8 3.0.3 with
node.js 0.3.2, however there is no node.js related code in example). I
guess some optimization is going on I'm not aware of. But anyone who
can shine a light would be a great help!
#####################################
function loop(y) {
var len = 1000*1000*10;
var object = {};
var start = Date.now();
while (len--) {
object[y] = "someValue";
}
return Date.now()-start;
};
var x = "test101"; // this is fast
var y = "test" + "101"; // this is slower ???
var tries = 10;
while (tries--) {
console.log("Fast:" + loop(x));
console.log("Slow:" + loop(y));
}
####################################
regards, Peter
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users