Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
filter vs. handwired for loop filtering
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 17_5_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 17
Operating system:
iOS 17.5.1
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Array_filter_method
10946371.0 Ops/sec
classic_for_loop_filter
6985743.0 Ops/sec
Script Preparation code:
var arr = new Array({ length: 10000 }, () => Math.floor(Math.random() * 1000));
Tests:
Array_filter_method
var isGreaterThan500 = val => val > 500; var filtered = arr.filter(isGreaterThan500)
classic_for_loop_filter
var l = arr.length var filtered = []; for (var i = 0; i < l; i++) { var val = arr[i]; if (val > 500) { filtered.push(val); } }