count obj props (v2)

Revision 2 of this benchmark created on


Setup

var obj = {};
    var arr = new Array(1000);
    for(var i = 0; i < 1000; i++){
     obj[i] = {"1":"test","adsjsakldjlsa":i+"eeqw"};
     arr[i] = {"1":"test","adsjsakldjlsa":i+"eeqw"}; 
    }

Test runner

Ready to run.

Testing in
TestOps/sec
get object length
var test_c = 0;
for(x in obj){
  test_c++;
}
ready
just for comparing
var test_c = 0;
var length = arr.length;
for(var i = 0; i < length; i++){
 test_c++;
}
ready
;)
var length = arr.length;
ready
Object.keys
var length = Object.keys(obj).length
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.