bar

Benchmark created by foo on


Preparation HTML

<script src="//ajax.googleapis.com/ajax/libs/prototype/1/prototype.js">
</script>
<script>
  var num = 5,
      array = [],
      obj = {
      1: [1, 2, 3, 4, 5],
      3: [3, 4]
      };
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
pure
num++;
while (--num > 0) {
  array.unshift(obj[num] && obj[num].length || 0);
}
ready
proto
num.times(function(n) {

  var i = (n + 1).toString(),
      
      
      amount = (obj[i] && obj[i].length) || 0;

  array.push(amount);

});
ready

Revisions

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