Separate function vs inline

Benchmark created on


Setup

function doStuff(x) {
	if (Math.random() + x) {
		console.log('foo');
	}
	return x;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Create function that calls existing
function doZ() {
	return doStuff(Math.random())
}
ready
Create function with inline
function createZ() {
	const x = Math.random();
	if (Math.random() + x) {
		console.log('foo');
	}
	return x;
}
ready

Revisions

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