Javascript Shallow clone vs Structured clone Performance

Benchmark created on


Description

Javascript Shallow Clone vs. Structured clone Performance

Setup

const sampleMap = new Map([
	["a", [11,12,13,14,15,16,7,8,9,10]],
	["b", [1,2,3,4,5,6,17,18,9,10]],
	["c", [1,2,3,4,5,61,17,8,9,10]],
	["d", [1,2,3,4,15,6,7,8,9,10]],
	["e", [1,2,3,4,15,6,7,8,9,10]],
	["f", [1,2,32,4,521,6,7,8,9,10]],
	["g", [1,2,33,4,5,6,7,8,9,10]],
	["h", [1,2,43,4,5,68,7,8,9,10]],
	["i", [1,2,53,4,5,6,7,8,9,10]],
	["j", [1,2,3,64,75,6,7,8,9,10]],
])

Test runner

Ready to run.

Testing in
TestOps/sec
Shallow copy using Constructor
new Map(sampleMap);
ready
Deep copy using structuredClone
structuredClone(sampleMap);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.