Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
JSON.stringify vs structuredClone vs customClone
JSON.stringify vs structuredClone vs customClone
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:139.0) Gecko/20100101 Firefox/139.0
Browser:
Firefox 139
Operating system:
Mac OS X 10.15
Device Platform:
Desktop
Date tested:
10 months ago
Test name
Executions per second
JSON.stringify
1656047.4 Ops/sec
structuredClone
1300236.2 Ops/sec
customClone
12339389.0 Ops/sec
Script Preparation code:
var customClone = function customClone(val) { var k, out, tmp; if (Array.isArray(val)) { out = Array(k = val.length); while (k--) out[k] = (tmp = val[k]) !== null && typeof tmp === 'object' ? customClone(tmp) : tmp; return out; } if (val !== null && typeof val === 'object') { out = {}; // null for (k in val) { if (k !== '__proto__') { out[k] = (tmp = val[k]) !== null && typeof tmp === 'object' ? customClone(tmp) : tmp; } } return out; } return val; } var MyObject = { description: 'Creates a deep copy of source, which should be an object or an array.', myNumber: 123456789, myBoolean: true, jayson: { stringify: 'JSON.stringify() method converts a JavaScript value to a JSON string....', parse: 'JSON.parse() method parses a JSON string...' } }; var myCopy = null;
Tests:
JSON.stringify
myCopy = JSON.parse(JSON.stringify(MyObject));
structuredClone
myCopy = structuredClone(MyObject);
customClone
myCopy = customClone(MyObject);