Setup Object with lots of functions vs array of functions

Benchmark created by Jason on


Description

Check the difference between adding lots functions to an object or add them to an array of functions.

Test runner

Ready to run.

Testing in
TestOps/sec
Object Setup
var obj = {};

for (var i = 0; i < 1000; i++)
{
  obj['f'+i] = function(){ return i; }
}

 
ready
Array Setup
var obj = {f:[]};

for (var i = 0; i < 1000; i++)
{
  obj.f[i] = function(){ return i; }
}

 
ready

Revisions

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

  • Revision 1: published by Jason on