Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
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
Benchmark engine:
Benchmark.js
DeepClone
109K/s
JSON.stringify
103K/s
View exact numbers
Test name
Executions per second
✓
DeepClone
109,355 Ops/sec
JSON.stringify
103,246 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));