record-functional-update

Benchmark created on


Setup

var a = {
	x1: 1,
	x2: 2.2,
	x3: "",
	x4: true,
	x5: null,
	x6: 1n,
	x7: {},
	x8: [],
	x9: new Map(),
	x10: 0,
}

Test runner

Ready to run.

Testing in
TestOps/sec
spread, update first field
var b = {
	...a,
	x1: 2
}
ready
spread, update last field
var b = {
	...a,
	x10: 2
}
ready
explicit, update first field
var b = {
	x1: 2,
	x2: a.x2,
	x3: a.x3,
	x4: a.x4,
	x5: a.x5,
	x6: a.x6,
	x7: a.x7,
	x8: a.x8,
	x9: a.x9,
	x10: a.x10,
}
ready
explicit, update last field
var b = {
	x1: a.x1,
	x2: a.x2,
	x3: a.x3,
	x4: a.x4,
	x5: a.x5,
	x6: a.x6,
	x7: a.x7,
	x8: a.x8,
	x9: a.x9,
	x10: 2,
}
ready

Revisions

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