Doing some tests on windows with node v0.8.11
--------------------------------------------
var buf = new Buffer(10000000);
buf.fill(0xFF);

var len = buf.length;
var a;
var start = new Date();
for(var b = 0 ; b < len; b++){
a = buf.readUInt8(b);
}
var end = new Date();

console.log('Buffer reads ' + (end - start) + ' ms'); // Prints 81ms

------------------------------------------------

var arr = [];
var len = 10000000;
for(b = 0 ; b < len; b++){
arr[b] = 0xFF;
}
var len = arr.length;
console.log(len);
start = new Date();
for(b = 0 ; b < len; b++){
a = arr[b];
}
end = new Date();

console.log('Array reads ' + (end - start) + ' ms'); // Prints 29ms

And I always thought that buffers would be faster than arrays in node.js ? 
:(
Am I doing something wrong ??



-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to