Object.is() performance

Benchmark created on


Setup

const makeObj = (val) => ({ val });
const arr = Array(256);
const cmpIdx = (Math.random() * arr.length) | 0;
arr[0] = makeObj(NaN);
for (let i = 1; i < arr.length; i++) {
	arr[i] = makeObj(Math.random());
}

Test runner

Ready to run.

Testing in
TestOps/sec
Triple Equality
const n = arr[cmpIdx];
let idx = -1;
for (let i = 1; i < arr.length; i++) {
	if (n === arr[i]) { idx = i; }
}
ready
Object.is() equality
const n = arr[cmpIdx];
let idx = -1;
for (let i = 1; i < arr.length; i++) {
	if (Object.is(n, arr[i])) { idx = i; }
}
ready

Revisions

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