Class construction

Benchmark created on


Description

Is there a difference between predefined fields and fields created at construction?

Setup

class Predefined {
	foo
	bar
	constructor(params) {
		this.foo = params.foo
		this.bar = params.bar
	}
}

class Virtual {
	constructor(params) {
		this.foo = params.foo
		this.bar = params.bar
	}
}


const iterations = 10_000

Test runner

Ready to run.

Testing in
TestOps/sec
Predefined
for (let i = 0; i < iterations; i += 1) {
	new Predefined({foo: 'foo', bar: 'bar'})
}
ready
Virtual
for (let i = 0; i < iterations; i += 1) {
	new Virtual({foo: 'foo', bar: 'bar'})
}
ready

Revisions

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