Shallow Copy Test

Benchmark created on


Description

what happens when I want to copy objects a lot

Setup

data = []
let i
for(i = 0; i < 1000000; i++){
	data[i] = {"title": `product ${i+1}`, id: i}
}

Teardown

for(j = 0; j < data.length; j++){
	data[j] = tx(data[j])
}

Test runner

Ready to run.

Testing in
TestOps/sec
Control
function tx(row){
	row['image'] = "https://example.com/test.jpg"
	return row
}
ready
Added Shallow Copy
function tx(row){
	let shallow = {...row}
	shallow['image'] = "https://example.com/test.jpg"
	return shallow
}
ready

Revisions

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