Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Underscore vs native groupby
(version: 0)
Comparing performance of:
Underscore vs Native
Created:
4 years ago
by:
Guest
Jump to the latest result
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.9.0/underscore.js"></script>
Script Preparation code:
var data = [ { "collectionOrder": { "customer_full_address": "Marmoleria 306, 20 de Noviembre, 15300, Venustiano Carranza Ciudad de México", "customer_full_name": "Ivan Arturo Segura Ramirez", "customer_mobile_number": "5511223344", "id": 1, "latitude": 19.45027, "longitude": -99.10759, "priority": 0, "status": "pendant", }, "orders": [ { "alternative_tracking_number": "ART456789", "cod_amount": null, "customer_address_reference": null, "customer_city": "Ciudad de México", "customer_collection_id": 1, "customer_country": "México", "customer_email": "arturo@bigsmart.mx", "customer_external_number": "306", "customer_first_name": "Ivan Arturo", "customer_internal_number": null, "customer_last_name": "Segura Ramirez", "customer_mobile_number": "5511223344", "customer_municipality": "Venustiano Carranza", "customer_phone_number": null, "customer_postcode": "15300", "customer_settlement": "20 de Noviembre", "customer_state": "Ciudad de México", "customer_street": "Marmoleria", "delivery_deadline_date": "2021-05-19 00:00:00", "delivery_range": null, "delivery_verification": 0, "estimated_delivery_date": "2021-05-19 00:00:00", "id": 268438, "latitude": 19.45027, "longitude": -99.10759, "priority": null, "purchase_order_number": "456789", "status": "pendant", "tracking_number": "6928948347520311", "verification_code": "735237", "warning": "no", }, { "alternative_tracking_number": "ART778899", "cod_amount": null, "customer_address_reference": null, "customer_city": "Ciudad de México", "customer_collection_id": 1, "customer_country": "México", "customer_email": "arturo@bigsmart.mx", "customer_external_number": "306", "customer_first_name": "Ivan Arturo", "customer_internal_number": null, "customer_last_name": "Segura Ramirez", "customer_mobile_number": "5527216833", "customer_municipality": "Venustiano Carranza", "customer_phone_number": null, "customer_postcode": "15300", "customer_settlement": "20 de Noviembre", "customer_state": "Ciudad de México", "customer_street": "Marmoleria", "delivery_deadline_date": "2021-05-19 00:00:00", "delivery_range": null, "delivery_verification": 0, "estimated_delivery_date": "2021-05-19 00:00:00", "id": 268444, "latitude": 19.45027, "longitude": -99.10759, "priority": null, "purchase_order_number": "778899", "status": "pendant", "tracking_number": "4080568021863712", "verification_code": "064642", "warning": "no", }, ], "priority": 0, "status": "pendant", }, { "alternative_tracking_number": null, "cod_amount": null, "customer_address_reference": "Lope de Vega 409, Polanco, Polanco V Secc ", "customer_city": "Ciudad de México", "customer_collection_id": null, "customer_country": "México", "customer_email": "eduardo@bigsmart.mx", "customer_external_number": "409", "customer_first_name": "Test 9", "customer_internal_number": "", "customer_last_name": "Test 9", "customer_mobile_number": "5555555555", "customer_municipality": "Miguel Hidalgo", "customer_phone_number": "", "customer_postcode": "11560", "customer_settlement": "Polanco V Sección", "customer_state": "Ciudad de México", "customer_street": "Lope de Vega", "delivery_deadline_date": "2020-12-01 00:00:00", "delivery_range": 200, "delivery_verification": 0, "estimated_delivery_date": "2020-12-01 00:00:00", "id": 265373, "latitude": 19.4310806, "longitude": -99.1874431, "priority": null, "purchase_order_number": "0000000009", "status": "on_route", "tracking_number": "0055243900475396", "verification_code": "765524", "warning": "no", }, { "alternative_tracking_number": null, "cod_amount": null, "customer_address_reference": "", "customer_city": "Ciudad de México", "customer_collection_id": null, "customer_country": "México", "customer_email": "prangu@hotmail.com", "customer_external_number": "1037", "customer_first_name": "JOSE ANGEL", "customer_internal_number": "", "customer_last_name": "GUTIERREZ CASTRO", "customer_mobile_number": "3338146300", "customer_municipality": "Benito Juárez", "customer_phone_number": "", "customer_postcode": "03610", "customer_settlement": "Américas Unidas", "customer_state": "Ciudad de México", "customer_street": "CALZADA DE TLALPAN", "delivery_deadline_date": "2021-05-05 00:00:00", "delivery_range": 300, "delivery_verification": 0, "estimated_delivery_date": "2021-05-05 00:00:00", "id": 267895, "latitude": 19.38098, "longitude": -99.14025, "priority": null, "purchase_order_number": "PR128", "status": "pendant", "tracking_number": "6746555273433466", "verification_code": "936641", "warning": "no", } ]; function groupBy(xs, key) { return xs.reduce(function(rv, x) { (rv[x[key]] = rv[x[key]] || []).push(x); return rv; }, {}); };
Tests:
Underscore
var result = _.groupBy(data, 'status');
Native
var result = groupBy(data, 'status');
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
Underscore
Native
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!
Autogenerated LLM Summary
(model
llama3.2:3b
, generated one year ago):
The task at hand involves analyzing benchmark results to determine which implementation of the `groupBy` function is faster: the native JavaScript implementation or the one using Underscore.js. Given the data: **Individual test cases** * For Underscore: + "Benchmark Definition": `var result = _.groupBy(data, 'status');` + "Test Name": "Underscore" * For Native: + "Benchmark Definition": `var result = groupBy(data, 'status');` + "Test Name": "Native" **Latest benchmark result** * Two entries for Firefox 91 on Mac OS X 10.15: 1. "ExecutionsPerSecond" (native): 17953302.0 2. "ExecutionsPerSecond" (Underscore): 8576520.0 Based on the benchmark results, it appears that the native JavaScript implementation outperforms the Underscore.js version by a significant margin. Therefore, I would recommend using the native JavaScript implementation for the `groupBy` function.
Related benchmarks:
groupBy vs set
# Vijay => To test the performance of lodash groupby vs native JS groupby implementation
Underscore vs native sortby
Underscore vs native flat
Comments
Confirm delete:
Do you really want to delete benchmark?