Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
i hate l00ps
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (iPhone; CPU iPhone OS 15_8_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.6.6 Mobile/15E148 Safari/604.1
Browser:
Mobile Safari 15
Operating system:
iOS 15.8.2
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
functional
429.0 Ops/sec
imperative
255.0 Ops/sec
functional but better
403.4 Ops/sec
Script Preparation code:
var numbers = Array.from({ length: 10_000 }).map(() => Math.random())
Tests:
functional
const result = numbers .map(n => Math.round(n * 10)) .filter(n => n % 2 === 0) .reduce((a, n) => a + n, 0)
imperative
let result = 0 for (let i = 0; i < numbers.length; i++) { let n = Math.round(numbers[i] * 10) if (n % 2 !== 0) continue result = result + n }
functional but better
const round = n => Math.round(n * 10) const isEven = n => n % 2 === 0 const result = numbers .reduce((a, n) => { n = round(n) return isEven(n) ? a + n : a; }, 0)