range creation (v2)

Revision 2 of this benchmark created on


Setup

function getRangeArrayFrom(startFrom, until) {
  return Array.from({ length: until + 1 - startFrom }, (_, k) => k + startFrom);
}

function rangeKeysSpread(startFrom, until) {
    return [...Array(until - startFrom + 1).keys()].map(i => i + startFrom);
}

function loop (startFrom, until) {
	const result = [];
	for (let i = startFrom; i <= until; i++) {
		result.push(i);
	}
	return result;
}

Test runner

Ready to run.

Testing in
TestOps/sec
getRangeArrayFrom
getRangeArrayFrom(0, 1000)
ready
rangeKeysSpread
rangeKeysSpread(0, 1000)
ready
loop
loop(0, 1000)
ready

Revisions

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