Using object method

Benchmark created on


Setup

class Class1
{
	method() {}
}

const instance1 = new Class1();

const objectWithDefaultPrototype = {
	method() {},
}

const objectWithPrototypeOtherObject = {
	__proto__: objectWithDefaultPrototype,
};

const objectWithChangedPrototype = {};

Object.setPrototypeOf(objectWithChangedPrototype, objectWithDefaultPrototype);

const REPEATS_COUNT = 1_000_000;

Test runner

Ready to run.

Testing in
TestOps/sec
Class instance
for (let i = 0; i < REPEATS_COUNT; i++)
{
	instance1.method();
}

ready
Object with default prototype
for (let i = 0; i < REPEATS_COUNT; i++)
{
	objectWithDefaultPrototype.method();
}
ready
Object with changed prototype
for (let i = 0; i < REPEATS_COUNT; i++)
{
	objectWithChangedPrototype.method();
}
ready

Revisions

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