Constant? (v2)

Revision 2 of this benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
==
function equals(test, secret) {
  // String comparison that does not leak timing information
  let diffs = test.length !== secret.length ? 1 : 0;
  for (let i = 0; i < test.length; i++) diffs += (test[i] === secret[i]? 0 : 1);
  return diffs == 0;
}

equals("12345678901234567890", "12345678901234567890")
ready
!=
function equals(test, secret) {
  // String comparison that does not leak timing information
  let diffs = test.length !== secret.length ? 1 : 0;
  for (let i = 0; i < test.length; i++) diffs += (test[i] === secret[i]? 0 : 1);
  return diffs == 0;
}

equals("12345678901234567890", "01234567890123456789")
ready

Revisions

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