Direct function execution or using "call" (v2)

Revision 2 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) !== AnotherObject) {
	throw new Error('failed');
}
ready
Using call
if (method2.call(AnotherObject) !== AnotherObject) {
	throw new Error('failed');
}
ready
Using object call
if (instance.method() !== 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.