bind vs closure (v4)

Revision 4 of this benchmark created on


Setup

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

const numOfRuns = 10000000

Test runner

Ready to run.

Testing in
TestOps/sec
closure
const closureFunction = (num1) => {
	test(10, num1)
}
for(let i = 0; i < numOfRuns; ++i) {
	closureFunction(i);
}
ready
bind
const bindFunction = test.bind(null, 10);
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
function newTest(num1) {
	test(10, num1)
}
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.