Test for default callbacks (v2)

Revision 2 of this benchmark created on


Setup

function test0(v, cb = () => {}) {
	cb(v);
}
function test1(v, cb) {
	cb?.(v);
}
function test2(v, cb) {
	cb(v);
}

Test runner

Ready to run.

Testing in
TestOps/sec
Defaulted callback
for(let i = 0; i < 10000; i++) {
	test0(i);
}
ready
Callback with nullable test
for(let i = 0; i < 10000; i++) {
	test1(i);
}
ready
Force provision of callback
for(let i = 0; i < 10000; i++) {
	test2(i, () => {});
}
ready
Defaulted callback (but with supplied callback)
for(let i = 0; i < 10000; i++) {
	test0(i, () => {});
}
ready
Callback with nullable test (but with supplied callback)
for(let i = 0; i < 10000; i++) {
	test1(i, () => {});
}
ready

Revisions

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