Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
structuredClone vs Immer Produce
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36 Edg/124.0.0.0
Browser:
Chrome 124
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
immer.produce()
292626.3 Ops/sec
structuredClone
103.0 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 = 3; 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(() => ({})), }, };
Tests:
immer.produce()
const result = immer.produce(state, draft => { draft.data.data1.data2 = 'updated'; for (let i; i < 500; i++) { draft.data.data1.siblilngs[i] = { id: uuidv4() }; } })
structuredClone
const result = structuredClone(state); result.data.data1.data2 = 'updated'; for (let i; i < 500; i++) { result.data.data1.siblilngs[i] = { id: uuidv4() }; }