bind vs closure (v3)

Revision 3 of this benchmark created on


Setup

function test(testVariable, num1) {
	Math.pow(testVariable, num1)
}

const closureFunction = (num1) => {
	test(10, num1)
}

function newTest(num1) {
	test(10, num1)
}

const bindFunction = test.bind(null, 10);

const numOfRuns = 1000000

Test runner

Ready to run.

Testing in
TestOps/sec
closure

for(let i = 0; i < numOfRuns; ++i) {
	closureFunction(i);
}
ready
bind

for(let i = 0; i < numOfRuns; ++i) {
	bindFunction (i);
}
ready
call
for(let i = 0; i < numOfRuns; ++i) {
	test.call(null, 10, i)
}
ready
function def

for(let i = 0; i < numOfRuns; ++i) {
	newTest(i);
}
ready

Revisions

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