Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Array.filter vs push
Compare array ops to remove elements from array
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64; rv:141.0) Gecko/20100101 Firefox/141.0
Browser:
Firefox 141
Operating system:
Linux
Device Platform:
Desktop
Date tested:
8 months ago
Test name
Executions per second
filter
322446.8 Ops/sec
push
514010.6 Ops/sec
Script Preparation code:
var array = []; for (var idx = 0; idx < 1000; idx++) { array[idx] = idx; } function oddNum(item) { return item % 2; } // Create a new array and push to it Array.prototype.pushFilter = function(condition) { // Create a new array and push to it var result = []; for(var i = 0, len = this.length; i < len; i++) { if (condition(this[i], i, this)) result.push(this[i]); } return result; };
Tests:
filter
var result = array.filter(oddNum);
push
var result = array.pushFilter(oddNum);