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 (iPhone; CPU iPhone OS 17_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4.1 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 17
Operating system:
iOS 17.4.1
Device Platform:
Mobile
Date tested:
2 years ago
push
225K/s
filter
165K/s
View exact numbers
Test name
Executions per second
✓
push
225,450 Ops/sec
filter
165,000 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);