Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
JSON.stringify vs slice vs structuredClone vs spread vs Array.from
(version: 0)
Comparing performance of:
JSON.stringify vs slice vs Array from vs Spread
Created:
3 years ago
by:
Guest
Jump to the latest result
Script Preparation code:
var vertices = [ [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1], ] var myCopy = null;
Tests:
JSON.stringify
myCopy = JSON.parse(JSON.stringify(vertices));
slice
myCopy = vertices.slice();
Array from
myCopy = Array.from(vertices)
Spread
myCopy = [...vertices]
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (4)
Previous results
Fork
Test case name
Result
JSON.stringify
slice
Array from
Spread
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
one year ago
)
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36
Browser/OS:
Chrome 126 on Linux
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
JSON.stringify
1442503.9 Ops/sec
slice
9405252.0 Ops/sec
Array from
5418190.5 Ops/sec
Spread
8670161.0 Ops/sec
Related benchmarks:
JavaScript array copy via spread op vs slice
JSON.stringify vs slice
JSON stringify vs slice vs structuredClone vs spread vs Array from
Semi deep copy | JSON stringify vs slice vs structuredClone vs spread vs Array from
Comments
Confirm delete:
Do you really want to delete benchmark?