test (v7)

Revision 7 of this benchmark created on


Setup

function getRandomNumber(max, min) {
    max = max ?? Number.MAX_VALUE;
    min = min ?? 0;
    return min + Math.round(Math.random() * (max - min));
}
const data = Array(10000).fill(0).map(p => getRandomNumber());

const data2 = {};
for (let i = 0; i < data.length; i++) {
	data2[data[i]] = true;
}

Test runner

Ready to run.

Testing in
TestOps/sec
forin
const newArr = [];
for (const key in data2) {
	newArr.push(data2[key]);
}
ready
forof object.keys
const newArr = [];
for (const key of Object.keys(data2)) {
	newArr.push(data2[key]);
}
ready
forof object.values
const newArr = [];
for (const val of Object.values(data2)) {
	newArr.push(val);
}
ready

Revisions

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