Equality Comparisons (v2)

Revision 2 of this benchmark created on


Setup

const numbers = [];
const booleans = [];
const strings = [];
const coercion = [];
const mix = [];
const mixSelector = [numbers, booleans, strings]

for(let i=0; i<1000; i++) {
	numbers.push(i);
	booleans.push(!!i%2);
	strings.push('' + i);
	coercion.push({valueOf: () => i})
	const array = mixSelector[i%mixSelector.length];
	mix.push(array[i]);
}

Test runner

Ready to run.

Testing in
TestOps/sec
numbers ==
let sum = false;
for (i = 0; i< numbers.length; i++) {
	sum = numbers[i] == -1 || sum;
}
ready
numbers ===
let sum = false;
for (i = 0; i< numbers.length; i++) {
	sum = numbers[i] === -1 || sum;
}
ready
strings ==
let sum = false;
for (i = 0; i< strings.length; i++) {
	sum = strings[i] == -1 || sum;
}
ready
strings ===
let sum = false;
for (i = 0; i< strings.length; i++) {
	sum = strings[i] === -1 || sum;
}
ready
mix ==
let sum = false;
for (i = 0; i< mix.length; i++) {
	sum = mix[i] == -1 || sum;
}
ready
mix ===
let sum = false;
for (i = 0; i< mix.length; i++) {
	sum = mix[i] === -1 || sum;
}
ready
coercion ==
let sum = false;
for (i = 0; i< coercion.length; i++) {
	sum = coercion[i] === -1 || sum;
}
ready

Revisions

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