dojo forEach vs. native forEach

JavaScript performance comparison

Revision 3 of this test case created by Darth

Preparation code

<script src="https://ajax.googleapis.com/ajax/libs/dojo/1.8.3/dojo/dojo.js">
</script>
<script>
  require(["dojo/_base/array"], function(array) {
    window.dojoArray = array;
  });

  var arr10 = new Array(10),
      arr100 = new Array(100),
      arr1000 = new Array(1000),
      length10 = arr10.length,
      length100 = arr100.length,
      length1000 = arr1000.length,
      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 10 items
dojoArray.forEach(arr10, func);
pending…
dojo forEach 100 items
dojoArray.forEach(arr100, func);
pending…
dojo forEach 1000 items
dojoArray.forEach(arr1000, func);
pending…
Native forEach 10 items
arr10.forEach(func);
pending…
Native forEach 100 items
arr100.forEach(func);
pending…
Native forEach 1000 items
arr1000.forEach(func);
pending…
Native for 10 items
for (i = 0; i < length10; ++i) {
  func(arr10[i], i, arr10);
}
pending…
Native for 100 items
for (i = 0; i < length100; ++i) {
  func(arr100[i], i, arr100);
}
pending…
Native for 1000 items
for (i = 0; i < length1000; ++i) {
  func(arr1000[i], i, arr1000);
}
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