Spread vs structuredClone (v3)

Revision 3 of this benchmark created on


Setup

const myData = {
    width: 1170,
    height: 2532
};

Test runner

Ready to run.

Testing in
TestOps/sec
structuredClone
const result = structuredClone(myData);
ready
Spread
const result = { ...myData };
ready
Object.assign
const result = Object.assign({}, myData);
ready
JSON
const result = JSON.parse(JSON.stringify(myData));
ready
Manual implementation
const result = {
	width: myData.width,
	height: myData.height
}
ready
Object.entries
const result = {};
for ([key, value] of Object.entries(myData)) {
	result[key] = value;
}
ready

Revisions

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