compare numbers vs compare strings (v2)

Revision 2 of this benchmark created on


Setup

let a = 1;
let b = 2;
let c = 1;

let aa = "a";
let bb = "b";
let cc = "a";

let aaa = "abcdefg";
let bbb = "abcdefgh";
let ccc = "abcdefg";

let aaaa = 1.1;
let bbbb = 2.2;
let cccc = 1.1;

const f = Math.random() > 0.5;

Test runner

Ready to run.

Testing in
TestOps/sec
compare inequal numbers
a === b;
ready
compare equal numbers
a === c;
ready
compare numbers with unpredictable result
let t;
if (f) t = a; else t = b;

t === c;
ready
compare strings with unpredictable result
let t;
if (f) t = aaa; else t = bbb;

t === ccc;
ready
new Date
const t = new Date();
ready
inverse result
function a() {
	return true;
}

!a();
ready

Revisions

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