Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
array.toSorted vs structuredClone
(version: 1)
Which is faster for cloning?
Comparing performance of:
array.toSorted vs sturcturedClone
Created:
10 months ago
by:
Guest
Jump to the latest result
Script Preparation code:
var array = Array.from({ length: 10_000 }).map((_) => Math.random()); var compareFn = (a, b) => a - b
Tests:
array.toSorted
const result = array.toSorted(compareFn)
sturcturedClone
const result = structuredClone(array).sort(compareFn)
Rendered benchmark preparation results:
Suite status:
<idle, ready to run>
Run tests (2)
Previous results
Fork
Test case name
Result
array.toSorted
sturcturedClone
Fastest:
N/A
Slowest:
N/A
Latest run results:
Run details:
(Test run date:
10 months ago
)
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser/OS:
Chrome 137 on Windows
View result in a separate tab
Embed
Embed Benchmark Result
Test name
Executions per second
array.toSorted
633.3 Ops/sec
sturcturedClone
551.9 Ops/sec
Related benchmarks:
JavaScript Array.slice vs Array.slice(0)
JavaScript spread operator vs Slice/Splice performance 2edas
Slice vs spread array
JS Array Slice vs Array Spread
Array cloning 2023
Array cloning 2023 (2)
Lodash clone deep object array vs string array
Array clone (spread vs slice vs array.from)
shallow clone object vs map copy vs strucutredClone
Comments
Confirm delete:
Do you really want to delete benchmark?