Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Ramda vs Native Reduce Trials
(version: 0)
Comparing performance of:
Ramda Reduce vs Native Reduce vs Native Map + Reduce
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/ramda@0.27.0/dist/ramda.min.js"></script>
Script Preparation code:
var data = [ { "_id": "60affa2283b0efedaea3b1c4", "index": 0, "guid": "31db5e6e-7e70-4875-8da6-cd8bb4af4983", "isActive": true, "balance": "$2,186.30", "picture": "http://placehold.it/32x32", "age": 20, "eyeColor": "green", "name": "Willa Suarez", "gender": "female", "company": "CAPSCREEN", "email": "willasuarez@capscreen.com", "phone": "+1 (815) 416-2961", "address": "209 Woodhull Street, Weedville, Kansas, 1030", "about": "Aliqua eiusmod ipsum pariatur dolore pariatur consequat elit do elit labore nisi est consequat consectetur. Mollit commodo exercitation amet dolor nisi commodo velit Lorem laborum Lorem deserunt excepteur esse laborum. Consequat non est eiusmod aliquip. Est labore culpa et deserunt eu.\r\n", "registered": "2015-01-19T05:50:47 +05:00", "latitude": 21.473397, "longitude": -113.550715, "tags": [ "aliquip", "nulla", "proident", "ipsum", "sit", "elit", "incididunt" ], "friends": [ { "id": 0, "name": "Tamika Mcmillan" }, { "id": 1, "name": "Maribel Douglas" }, { "id": 2, "name": "Karla Lott" } ], "greeting": "Hello, Willa Suarez! You have 2 unread messages.", "favoriteFruit": "apple" }, { "_id": "60affa2252d756a2e4af735a", "index": 1, "guid": "0cf14e81-714b-4279-a937-6145c55e85df", "isActive": true, "balance": "$2,486.15", "picture": "http://placehold.it/32x32", "age": 34, "eyeColor": "green", "name": "Effie Waters", "gender": "female", "company": "COMVEX", "email": "effiewaters@comvex.com", "phone": "+1 (906) 432-3853", "address": "662 Marconi Place, Statenville, Kentucky, 7564", "about": "Ullamco nostrud dolor ea labore minim irure. Ullamco eiusmod voluptate irure fugiat enim. Lorem id aute enim ea duis ad eu anim cupidatat sint.\r\n", "registered": "2020-11-02T09:42:50 +05:00", "latitude": 17.133879, "longitude": 4.200852, "tags": [ "nulla", "et", "adipisicing", "nostrud", "amet", "ea", "et" ], "friends": [ { "id": 0, "name": "Therese Mayo" }, { "id": 1, "name": "Cross Chapman" }, { "id": 2, "name": "Stacy Cotton" } ], "greeting": "Hello, Effie Waters! You have 5 unread messages.", "favoriteFruit": "apple" }, { "_id": "60affa22b6ee227a033a0bd0", "index": 2, "guid": "19aad48c-d293-46b4-9cd0-c0831bb37359", "isActive": true, "balance": "$3,501.49", "picture": "http://placehold.it/32x32", "age": 21, "eyeColor": "green", "name": "Laura Lawson", "gender": "female", "company": "NIPAZ", "email": "lauralawson@nipaz.com", "phone": "+1 (826) 571-2542", "address": "790 Pulaski Street, Cochranville, Palau, 2071", "about": "Est cillum elit eiusmod exercitation reprehenderit enim. Ullamco proident elit incididunt cupidatat consectetur mollit. Anim eu sunt aute nisi commodo. Nulla tempor laboris voluptate sit consequat nisi in ipsum. Eu incididunt id ullamco sint fugiat pariatur exercitation Lorem qui occaecat esse sint aute in. Anim in esse consectetur elit tempor sint cillum ullamco labore. Velit et reprehenderit officia adipisicing fugiat ea incididunt sit adipisicing reprehenderit ullamco excepteur ea amet.\r\n", "registered": "2014-12-11T01:14:20 +05:00", "latitude": 74.245409, "longitude": -25.635153, "tags": [ "anim", "nostrud", "amet", "sit", "incididunt", "cillum", "esse" ], "friends": [ { "id": 0, "name": "Wilda Holland" }, { "id": 1, "name": "Burch Beck" }, { "id": 2, "name": "Tanner Watson" } ], "greeting": "Hello, Laura Lawson! You have 5 unread messages.", "favoriteFruit": "banana" }, { "_id": "60affa229b7bfd65d269f620", "index": 3, "guid": "2ad65c49-2e9d-4898-9cef-ef3e5da368bf", "isActive": true, "balance": "$3,247.93", "picture": "http://placehold.it/32x32", "age": 36, "eyeColor": "brown", "name": "Kidd Keller", "gender": "male", "company": "STEELTAB", "email": "kiddkeller@steeltab.com", "phone": "+1 (870) 410-2743", "address": "444 Junius Street, Orason, West Virginia, 4520", "about": "Quis aliqua commodo nisi et adipisicing labore labore aliquip nisi. Ex laboris velit officia labore laborum est. Enim quis culpa ea mollit Lorem eu est labore ut occaecat. Non voluptate cupidatat ullamco sunt commodo consequat laborum laboris veniam pariatur amet cupidatat ea eu. Officia qui pariatur labore magna occaecat officia enim.\r\n", "registered": "2017-02-24T02:37:31 +05:00", "latitude": 19.8666, "longitude": -5.043646, "tags": [ "dolor", "velit", "excepteur", "labore", "sit", "aliqua", "dolore" ], "friends": [ { "id": 0, "name": "Kim Dominguez" }, { "id": 1, "name": "Kemp Nixon" }, { "id": 2, "name": "Sherrie Cross" } ], "greeting": "Hello, Kidd Keller! You have 7 unread messages.", "favoriteFruit": "apple" }, { "_id": "60affa2239e4cbf16aafafbb", "index": 4, "guid": "258797fe-83b7-46ff-a8e1-48a4c9cb1dbc", "isActive": true, "balance": "$3,046.32", "picture": "http://placehold.it/32x32", "age": 28, "eyeColor": "green", "name": "Shelley Small", "gender": "female", "company": "ESCHOIR", "email": "shelleysmall@eschoir.com", "phone": "+1 (930) 443-2133", "address": "795 Bragg Street, Welch, Marshall Islands, 6091", "about": "Ea ut adipisicing velit ex aliquip eiusmod qui. Tempor proident esse sit amet eu id ex esse sunt et culpa consectetur dolore veniam. Dolor irure consectetur ea occaecat anim. Fugiat incididunt anim velit reprehenderit officia. Est velit consectetur veniam incididunt ullamco in officia.\r\n", "registered": "2016-02-20T10:29:19 +05:00", "latitude": -21.605153, "longitude": -79.017989, "tags": [ "labore", "laboris", "dolor", "deserunt", "incididunt", "eu", "anim" ], "friends": [ { "id": 0, "name": "Ilene Foley" }, { "id": 1, "name": "Avis Bolton" }, { "id": 2, "name": "Wagner Howard" } ], "greeting": "Hello, Shelley Small! You have 2 unread messages.", "favoriteFruit": "apple" }, { "_id": "60affa2207cd64ed6a0a1c57", "index": 5, "guid": "4dfc4423-6b24-4f0f-b5be-1ca28bfca3fe", "isActive": false, "balance": "$2,729.88", "picture": "http://placehold.it/32x32", "age": 30, "eyeColor": "brown", "name": "Lydia Hobbs", "gender": "female", "company": "PROGENEX", "email": "lydiahobbs@progenex.com", "phone": "+1 (801) 592-3944", "address": "983 Vermont Street, Boonville, Wisconsin, 4666", "about": "Cupidatat ad excepteur duis nisi. Est sit sint ullamco non velit in adipisicing mollit est nostrud et non. Cupidatat esse est nostrud minim dolore pariatur consequat irure. Adipisicing irure sit nisi pariatur commodo est ad occaecat anim amet in laboris et. Aute culpa sunt eiusmod minim nisi consectetur eiusmod consectetur aute. Laborum occaecat deserunt consequat non exercitation nostrud pariatur fugiat elit deserunt. Duis eu consequat labore consequat Lorem ipsum nisi.\r\n", "registered": "2018-08-03T04:17:23 +04:00", "latitude": -22.955688, "longitude": 100.655838, "tags": [ "nostrud", "exercitation", "dolore", "eiusmod", "ullamco", "elit", "exercitation" ], "friends": [ { "id": 0, "name": "Tia Slater" }, { "id": 1, "name": "Kramer Hays" }, { "id": 2, "name": "Graciela Chaney" } ], "greeting": "Hello, Lydia Hobbs! You have 4 unread messages.", "favoriteFruit": "strawberry" }, { "_id": "60affa220443474aacf11773", "index": 6, "guid": "92b6d59c-70cc-4ade-8814-aee38833cc77", "isActive": false, "balance": "$1,439.52", "picture": "http://placehold.it/32x32", "age": 38, "eyeColor": "brown", "name": "Hyde Mcconnell", "gender": "male", "company": "ZAGGLES", "email": "hydemcconnell@zaggles.com", "phone": "+1 (966) 580-2054", "address": "454 Henry Street, Savannah, Oregon, 6667", "about": "Adipisicing mollit eu est culpa ut sunt ut. In ad velit adipisicing sint mollit aliquip ullamco officia ut velit sunt eu tempor. Occaecat enim officia elit dolore. Quis nostrud est eu ipsum veniam non eiusmod cillum ad. Officia officia non qui est laboris. Et mollit quis dolore quis magna qui laborum non occaecat dolore sit occaecat.\r\n", "registered": "2014-07-11T01:03:57 +04:00", "latitude": 0.010282, "longitude": -85.416006, "tags": [ "culpa", "sint", "mollit", "adipisicing", "ut", "eu", "ut" ], "friends": [ { "id": 0, "name": "Nunez Camacho" }, { "id": 1, "name": "Kimberly Gonzales" }, { "id": 2, "name": "Gamble Hyde" } ], "greeting": "Hello, Hyde Mcconnell! You have 6 unread messages.", "favoriteFruit": "banana" } ]; var rReduce = R.pipe( R.map( R.props( ['index', 'name'] ) ), R.fromPairs );
Tests:
Ramda Reduce
rReduce(data);
Native Reduce
data.reduce((acc, curr) => { const { index, ...rest } = curr; acc[index] = { ...rest, }; return acc; }, {});
Native Map + Reduce
data .map(({ index, ...rest }) => ({ [index]: rest })) .reduce((acc, curr) => Object.assign(acc, curr), {});
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
Ramda Reduce
Native Reduce
Native Map + Reduce
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0
Browser/OS:
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
Ramda Reduce
1520673.5 Ops/sec
Native Reduce
430998.0 Ops/sec
Native Map + Reduce
326931.8 Ops/sec
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
I'll provide the final answer. The benchmark results indicate that Ramda's `reduce` function is the fastest among the three options, followed by native JavaScript reduce, and then native map + reduce. Here are the results with the corresponding times: 1. **Ramda Reduce**: 345139 executions per second 2. **Native Reduce**: 37958 executions per second 3. **Native Map + Reduce**: 31811 executions per second These results suggest that Ramda's optimized implementation of `reduce` is significantly faster than native JavaScript reduce, and even outperforms the combination of map and reduce operations in native code. However, please note that these results are based on a single benchmarking run, and actual performance may vary depending on the specific use case, data size, and other factors.
Related benchmarks:
Lodash vs JSON vs Ramda Clone vs old school ugly with moar json
Lodash vs JSON vs Ramda Clone vs fixed old school ugly with moar json
lodash groupBy vs Array.reduce 3
lodas2 groupBy vs Array.reduce
lodash groupBy vs Array.reduce vs Ramda on million items
Comments
Confirm delete:
Do you really want to delete benchmark?