Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JSON.stringify vs Deep Clone
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:133.0) Gecko/20100101 Firefox/133.0
Browser:
Firefox 133
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
DeepClone
109354.8 Ops/sec
JSON.stringify
103246.3 Ops/sec
Script Preparation code:
var obj = {}; var objCount = 100; for (let i = 0; i < objCount; i++) { obj[i] = [1, 2, 3]; } function deepClone(source) { return Array.isArray(source) ? source.map((item) => deepClone(item)) : source && typeof source === "object" ? Object.getOwnPropertyNames(source).reduce((o, prop) => { o[prop] = deepClone(source[prop]); return o; }, Object.create(Object.getPrototypeOf(source))) : source; }
Tests:
DeepClone
var clone = deepClone(obj);
JSON.stringify
var clone = JSON.parse(JSON.stringify(obj));