Triple equals vs Double equals (v6)

Revision 6 of this benchmark created on


Preparation HTML

<script>
  var i1;
  var i2;
  var s1;
  var s2;

function randomInt() {
   var ret = Math.round(Math.random() * 1E9);
   ret + "";
   return ret;
}
function randomIntStr() {
   var ret = Math.round(Math.random() * 1E9);
   ret += "";
   return ret;
}
function randomBool() {
   var ret = Math.round(Math.random() * 1E9);
   ret = (ret%2 == 1);
   return ret;
}
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
===(int)
i1 = randomInt(); i2 = randomInt();
if (i1 === i2) { i1 = i1 + 0; }
ready
==(int)
i1 = randomInt(); i2 = randomInt();
if (i1 == i2) { i1 = i1 + 0; }
ready
==(string)
s1 = randomIntStr(); s2 = randomIntStr();
if (s1 == s2) { s1 = s1 + ""; }
ready
===(string)
s1 = randomIntStr(); s2 = randomIntStr();
if (s1 === s2) { s1 = s1 + ""; }
ready
=== (different type)
i1 = randomInt(); s1 = randomIntStr();
if (i1 === s1) { i1 = i1 + 0; }
ready
== (different type)
i1 = randomInt(); s1 = randomIntStr();
if (i1 == s1) { i1 = i1 + 0; }
ready
=== (bool)
i1 = randomBool(); s1 = randomBool();
if (i1 === s1) { i1 = i1 + 0; }
ready
== (bool)
i1 = randomBool(); s1 = randomBool();
if (i1 == s1) { i1 = i1 + 0; }
ready

Revisions

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