class instance call vs lambda with capture

Benchmark created on


Setup

class Cls {
	base;
	constructor(base) { this.base = base; }
	test(nb) { return this.base + nb; }
}

const cls = new Cls(15);

const factory = (base) => (nb) => base + nb;
const lambda = factory(15);

Test runner

Ready to run.

Testing in
TestOps/sec
class
cls.test(5);
ready
capture
lambda(5);
ready

Revisions

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