v1
- by victor-homyakov 10/27/202000
Setup HTML - click to add setup HTML
disable setup JavaScript
Setup JavaScript
const array = [];
for (let i = 0; i < 10000; i++) {
	array.push(i);
}
let result = 0; // accumulate benchmark results so that optimizer cannot throw out any part of our code

delete caserun single casemove downdrag and drop case


ready



const res = _(array).filter(n => n % 2).map(n => Math.sqrt(n)).take(5).value();
result += res[0];

delete caserun single casemove upmove downdrag and drop case


ready



const res = array.filter(n => n % 2).map(n => Math.sqrt(n)).slice(0, 5);
result += res[0];

delete caserun single casemove updrag and drop case


ready



const res = [];
for (let i = 0; i < array.length; i++) {
	const n = array[i];
	if (n % 2) { // filter(n => n % 2)
		const n2 = Math.sqrt(n); // map(n => Math.sqrt(n))
		res.push(n2);
		if (res.length >= 5) break; // take(5)
	}
}
result += res[0];

Test Case - click to add another test case
Teardown JS - click to add teardown JavaScript
Output (DOM) - click to monitor output (DOM) while test is running
RUN