Loop check

JavaScript performance comparison

Test case created by Kirill Borzov

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var i = 0;
  var Arr = Array.from({length:100},(_,i)=>++i);
  var result = 0

};
</script>

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
for full
for (var i = 0, len = Arr.length; i < len; i++) {
  result += i;
}
pending…
half for
for (var i = -1, len = Arr.length; ++i < len;) {
  result += i;
}
pending…
for reverse
for (var i = Arr.length; i > 0;i--) {
  result += i;
}
pending…
for in
for (var i in Arr) {
  result += Arr[i];
}
pending…
for of
for (var i of Arr) {
  result += i;
}
pending…
filter
Arr.filter(function(i) {
  result += i;
})
pending…
forEach
Arr.forEach(function(i) {
    result += i
});
pending…

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

0 Comments