for (v2)

Revision 2 of this benchmark created on


Setup

var values = Array.from({ length: 100 }, () => Math.random());

function shuffle() {
	values.sort(() => .5 - Math.random());
}

Test runner

Ready to run.

Testing in
TestOps/sec
for
shuffle();
let result = '';
for (let i = 0; i < values.length; ++i) {
	result += values[i];
}
ready
for-of
shuffle();
let result = '';
for (const value of values) {
	result += value;
}
ready
.forEach()
shuffle();
let result = '';
values.forEach((value) => {
	result += value;
});
ready

Revisions

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