Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Lodash CloneDeep vs Immer Produce with heavy load, slightly less useless
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15
Browser:
Safari 16
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
immer.produce()
120030.9 Ops/sec
_.cloneDeep
7.4 Ops/sec
HTML Preparation code:
<script src="https://cdn.jsdelivr.net/npm/immer@3.1.3/dist/immer.umd.min.js"></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.5/lodash.min.js'></script> <script src="https://cdn.jsdelivr.net/npm/uuid@8.3.2/dist/umd/uuidv4.min.js"></script>
Script Preparation code:
const numSiblings = 500; const depth = 5; state = { data: { data1: { data2: 'test', siblings: Array.from({ length: numSiblings }).map(() => ({ id: uuidv4() })), children: Array.from({ length: depth }).map(() => ({ id: uuidv4(), data: { data1: { data2: 'test', siblings: Array.from({ length: numSiblings }).map(() => ({ id: uuidv4() })), children: Array.from({ length: depth }).map(() => ({ id: uuidv4(), data: { data1: { data2: 'test', siblings: Array.from({ length: numSiblings }).map(() => ({ id: uuidv4() })), children: Array.from({ length: depth }).map(() => ({ id: uuidv4(), data: { data1: { data2: 'test', siblings: Array.from({ length: numSiblings }).map(() => ({ id: uuidv4() })), }, }, })), }, }, })), }, }, })), }, data3: Array.from({ length: 1000 }).map(() => document.createElement('div')), }, };
Tests:
immer.produce()
const result = immer.produce(state, draft => { draft.data.data1.data2 = 'updated' })
_.cloneDeep
const result = _.cloneDeep(state); result.data.data1.data2 = 'updated';