array.from vs push (v2)

Revision 2 of this benchmark created on


Preparation HTML

	

Setup

const array = new Array(100);
function* gen(array) {
	for (let i = 0; i < array.length; i++){
		yield array[i];
	}
}
function push(iterable){
	const iterator = iterable[Symbol.iterator]();
	const ret = [];
	let state;
	while ((state = iterator.next()) && !state.done){
		ret.push(state.value);
	}
	return ret;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Array.from
Array.from(gen(array));
ready
push
push(array)
ready
Array.from 2
Array.from(array[Symbol.iterator]());
ready

Revisions

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