Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
structuredClone vs JSON Stringify+Parse vs manual clone
(version: 1)
Comparing performance of:
structuredClone vs JSON Stringify+Parse vs Manual clone
Created:
4 months ago
by:
Registered User
Jump to the latest result
Script Preparation code:
var object = { type: "FeatureCollection", features: [{ type: "Feature", properties: {}, geometry: { type: "Point", coordinates: [4.483605784808901, 51.907188449679325] } }, { "type": "Feature", "properties": {}, "geometry": { "type": "Polygon", "coordinates": [ [ [3.974369110811523, 51.907355547778565], [4.173944459020191, 51.86237166892457], [4.3808076710679416, 51.848867725914914], [4.579822414365026, 51.874487141880024], [4.534413416598767, 51.9495302480326], [4.365110733567974, 51.92360787140825], [4.179550508127079, 51.97336560819281], [4.018096293847009, 52.00236546429852], [3.9424146309028174, 51.97681895676649], [3.974369110811523, 51.907355547778565] ] ] } } ] }; var copy = null; // Manual clone function deepCloneJsonValue(value) { if (value === null || typeof value !== "object") return value; if (Array.isArray(value)) return deepCloneJsonArray(value); return deepCloneJsonObject(value); } function deepCloneJsonObject(obj) { const cloned = { ...obj }; for (const key in cloned) { const value = cloned[key]; if (typeof value !== "object" || value === null) continue; cloned[key] = Array.isArray(value) ? deepCloneJsonArray(value) : deepCloneJsonObject(value); } return cloned; } function deepCloneJsonArray(arr) { const cloned = []; for (let i = 0, len = arr.length; i !== len; i++) { cloned.push(deepCloneJsonValue(arr[i])); } return cloned; }
Tests:
structuredClone
copy = structuredClone(object);
JSON Stringify+Parse
copy = JSON.parse(JSON.stringify(object));
Manual clone
copy = deepCloneJsonValue(object);
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (3)
Previous results
Fork
Test case name
Result
structuredClone
JSON Stringify+Parse
Manual clone
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
4 months ago
)
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36
Browser/OS:
Chrome 142 on Mac OS X 10.15.7
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
structuredClone
434204.9 Ops/sec
JSON Stringify+Parse
659703.8 Ops/sec
Manual clone
3315125.2 Ops/sec
Related benchmarks:
lodash vs json
Large JSON - Lodash CloneDeep vs JSON Stringify/Parse
Lodash cloneDeep vs JSON parse+stringify test
Lodash cloneDeep vs JSON.stringify + JSON.parse
lodash clonedeep vs json.parse(stringify())
JSON Parse vs StructuredClone bigger object
clonedeep vs structuredclone vs jsonstringify parse
JSON.stringify vs structuredClone 1
Clone object
Comments
Confirm delete:
Do you really want to delete benchmark?