Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash MapValue vs Pure JS
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Mobile Safari/537.36
Browser:
Chrome Mobile 122
Operating system:
Android
Device Platform:
Mobile
Date tested:
2 years ago
Test name
Executions per second
Lodash Test
22365.8 Ops/sec
Pure JS Test
22093.7 Ops/sec
HTML Preparation code:
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.15/lodash.min.js"></script>
Script Preparation code:
function format_lodash(data) { return data.map(({ id, label, ...properties}) => { return { id, label, properties: _.mapValues(properties, v => v[0]) }; }); } function format_pure(data) { return data.map(({ id, label, ...properties}) => { for (let [key, value] of Object.entries(properties)) { properties[key] = value[0] } return { id, label, properties}; }); }
Tests:
Lodash Test
const input = [{ id: 1, label: 'label 1', property_1: ['prop_1'], property_2: ['prop_2'] }, { id: 2, label: 'label 2', property_3: ['prop_3'], property_4: ['prop_4'] } ] console.log(format_lodash(input))
Pure JS Test
const input = [{ id: 1, label: 'label 1', property_1: ['prop_1'], property_2: ['prop_2'] }, { id: 2, label: 'label 2', property_3: ['prop_3'], property_4: ['prop_4'] } ] console.log(format_lodash(input))