Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Array.filter vs Array.push
(version: 0)
Comparing performance of:
filter vs push
Created:
2 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
const array = []; for (let i = 0; i < 1000; i++) { array[i] = i; } function checkCondition(item) { return item % 2; } Array.prototype.pushFilter = function(condition) { const result = []; for(let i = 0; i < this.length; i++) { if (condition(this[i], i, this)) result.push(this[i]); } return result; };
Tests:
filter
const result = array.filter(checkCondition);
push
const result = array.pushFilter(checkCondition);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
filter
push
Fastest:
N/A
Slowest:
N/A
Latest run results:
No previous run results
This benchmark does not have any results yet. Be the first one
to run it!
Comments
Confirm delete:
Do you really want to delete benchmark?