dojo forEach vs. native forEach

JavaScript performance comparison

Test case created by Mike McKenzie

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.8.2/dojo/dojo.js">
</script>
<script>
  var dojoArray;
  require(["dojo/_base/array"], function(array) {
    window.dojoArray = array;
  });
</script>
<script>
  var arr = new Array(100);
  var length = arr.length;
  var i;

  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
dojoArray.forEach(arr, func);
pending…
Array forEach
arr.forEach(func);
pending…
Native for loop
for (i = 0; i < length; ++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