Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
lodash set vs custom set
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36
Browser:
Chrome 134
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
lodash set
4912472.0 Ops/sec
custom set
12998907.0 Ops/sec
HTML Preparation code:
<script scr="https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js"></script>
Script Preparation code:
function set(object, path, value) { if (path in object) { object[path] = value; return; } path = path.split('.'); //extract last item and store it const lastProp = path.pop(); if (path.length) { let obj = object; let prop; for (prop of path) { if (prop in obj) { obj = obj[prop]; } else { return; } } obj[lastProp] = value; } } var testObject = { a: { b: 1 } }
Tests:
lodash set
_.set(testObject, 'a.b', 2)
custom set
set(testObject, 'a.b', 2)