Array.filter() vs. Array.entries().filter()

Benchmark created on


Setup

let sum = 0;
const arr = [100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55,100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55,100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55,100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55,100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55,100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55,100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55,100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55,100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55,100,83,39,34,59,27,20,50,76,54,60,40,12,32,57,6,21,7,84,15,25,24,90,31,51,48,62,91,88,23,35,61,52,49,95,81,64,63,79,46,96,29,28,19,53,93,72,38,98,58,56,99,2,13,14,26,67,80,82,89,75,47,74,73,66,5,8,17,37,92,16,44,4,43,1,70,42,3,45,11,71,77,30,69,68,87,65,97,94,9,36,33,41,22,78,18,85,86,10,55];

Test runner

Ready to run.

Testing in
TestOps/sec
Array.filter()
for (const e of arr.filter(e => e < 51)) {
	sum += e;
}
ready
Array.entries().filter()
for (const e of arr.entries().filter(e => e < 51)) {
	sum += e;
}
ready

Revisions

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