Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
forEach vs mapfilter vs transduce
(version: 0)
Comparing performance of:
forEach vs mapFilter vs transduce
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/ramda/0.25.0/ramda.min.js"></script>
Script Preparation code:
var makeArr = (randomCeil) => (len) => Array.from({ length: len }, (v, i) => Math.floor(Math.random() * randomCeil)); var arrOfMillion = makeArr(100)(1e6); var tripleIt = (num) => num * 3; var isEven = (num) => num % 2 === 0;
Tests:
forEach
const result = []; arrOfMillion.forEach((item) => { const tripleItem = tripleIt(item); if (isEven(tripleItem)) { result.push(tripleItem); } });
mapFilter
const result = arrOfMillion.map(tripleIt).filter(isEven);
transduce
const transducer = R.compose(R.filter(isEven), R.map(tripleIt)); const reducer = (acc, val) => (acc.push(val), acc); // same as (acc, val) => { acc.push(val); return acc } const result = R.transduce(transducer, reducer, [], arrOfMillion);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
forEach
mapFilter
transduce
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!
Related benchmarks:
Ramda map vs Array.map
Ramda map vs Array.map
Ramda map vs Array.map vs for loop
Ramda map vs Array.map vs for
MapFilter (Native vs Ramda) 0.28
Comments
Confirm delete:
Do you really want to delete benchmark?