Direct function execution or using "call" (v3)

Revision 3 of this benchmark created on


Setup

function method1(test) {
  return test;
}
function method2() {
  return this;
}
const AnotherObject = {};

class MyClass {
	method = method2;
}
const instance = new MyClass();

Test runner

Ready to run.

Testing in
TestOps/sec
Direct execution
if (method1(AnotherObject, Math.random()) !== AnotherObject) {
	throw new Error('failed');
}
ready
Using call
if (method2.call(AnotherObject, Math.random()) !== AnotherObject) {
	throw new Error('failed');
}
ready
Using object call
if (instance.method(Math.random()) !== instance) {
	throw new Error('failed');
}
ready

Revisions

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