bind vs closure (v2)

Revision 2 of this benchmark created on


Setup

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

const numOfRuns = 1000000

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
function
const closureFunction = function(num1) {
	test(10, num1)
}
for(let i = 0; i < numOfRuns; ++i) {
	closureFunction(i);
}
ready
call
for(let i = 0; i < numOfRuns; ++i) {
	test.call(null, 10, i)
}
ready
arrow
const closureFunction = (num1) => test(10, num1)
for(let i = 0; i < numOfRuns; ++i) {
	closureFunction(i);
}
ready
direct

for(let i = 0; i < numOfRuns; ++i) {
	test(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.