symbol vs string in === (v2)

Revision 2 of this benchmark created on


Setup

const sym1 = Symbol("foo");
const sym2 = Symbol("bar");

const str1 = "foo";
const str2 = "bar";

function doEqualForSym(a, b) {
  return a === b;
}
function doEqualForStr(a, b) {
  return a === b;
}

Test runner

Ready to run.

Testing in
TestOps/sec
sym1 === sym1
for (let i = 0; i < 1000; i++) {
  doEqualForSym(sym1, sym1);
}
console.log("ok 1 # sym1 === sym1");
ready
sym1 === sym2
for (let i = 0; i < 1000; i++) {
  doEqualForSym(sym1, sym2);
}
console.log("ok 2 # sym1 === sym2");
ready
str1 === str1
for (let i = 0; i < 1000; i++) {
  doEqualForStr(str1, str1);
}
console.log("ok 3 # str1 === str1");
ready
str1 === str2
for (let i = 0; i < 1000; i++) {
  doEqualForStr(str1, str2);
}
console.log("ok 4 # str1 === str2");
ready

Revisions

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