dojo forEach vs. native forEach

JavaScript performance comparison

Revision 5 of this test case created by Mike McKenzie

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.9.0/dojo/dojo.js">
</script>
<script>
  var dojoArray;
  require(["dojo/_base/array"], function(array) {
    window.dojoArray = array;
  });
</script>
      
<script>
Benchmark.prototype.setup = function() {
  var arr = new Array(100);
  
  function func(item, index, arr) {
    //do nothing
  }

};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
dojo forEach
(function anon1() {
  dojoArray.forEach(arr, func);
}());
pending…
Array forEach
(function anon2() {
  arr.forEach(func);
}());
pending…
Native for loop
(function anon3() {
  var i, l;
  for (i = 0, l = arr.length; i < l; ++i) {
    func(arr[i], i, arr);
  }
}());
pending…

Compare results of other browsers

Revisions

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

0 Comments