Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Object.assign vs. JSON String/Parse vs deepclone
Creating a "new" object reference every time
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Browser:
Chrome 130
Operating system:
Mac OS X 10.15.7
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
deepclone
167270352.0 Ops/sec
JSON Parse
120818824.0 Ops/sec
Object.assign
166235760.0 Ops/sec
Tests:
deepclone
function deepClone(obj) { if (obj === null || typeof obj !== 'object') { return obj; } const clone = Array.isArray(obj) ? [] : {}; for (let key in obj) { if (obj.hasOwnProperty(key)) { clone[key] = deepClone(obj[key]); } } return clone; } var n = {foo: 'bar', hello: [{hello: 'world', foo: 'bar'},{hello: 'world', foo: 'bar'},{hello: 'world', foo: 'bar'},{hello: 'world', foo: 'bar'}]}; while (n.length < 1000) { n = deepClone(n); }
JSON Parse
var n = {foo: 'bar', hello: [{hello: 'world', foo: 'bar'},{hello: 'world', foo: 'bar'},{hello: 'world', foo: 'bar'},{hello: 'world', foo: 'bar'}]}; while(n.length < 1000) { n = JSON.parse(JSON.stringify(n)) }
Object.assign
var n = {foo: 'bar', hello: [{hello: 'world', foo: 'bar'},{hello: 'world', foo: 'bar'},{hello: 'world', foo: 'bar'},{hello: 'world', foo: 'bar'}]}; while(n.length < 1000) { n = Object.assign({}, n); }