condition-vs-regex-every-loop

JavaScript performance comparison

Test case created by condition-vs-every-loop

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var a = 1, b = 2, c = 3, d = 4, e = 5;
    function isTrue(vars, vals) {
      return vals.every(function(val,i){ return vars[i] == val });
    }
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
condional
if (a == 1 && b == 2 && c == 3 && d == 4 && e == 5) {
 console.log('hey');
}
pending…
every
if (isTrue([a,b,c,d,e], [1,2,3,4,5])) {
  console.log('hey');
}
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. Here’s a list of current revisions for this page:

0 comments

Add a comment