Test calls perfs (v7)

Revision 7 of this benchmark created on


Setup

let A = 0;

function foo(a) {
	A += a
}

const FOO = Symbol()

class B {}
B.prototype.foo = foo;
B.prototype.foofoofoo = foo;
B.prototype[FOO] = foo;

const FAA = Symbol()
Object.defineProperty(B.prototype, FAA, {
	value: foo,
	enumerable: false,
	configurable: false,
	writtable: false
})
Object.defineProperty(B.prototype, "foo_A", {
	value: foo,
	enumerable: false,
	configurable: false,
	writtable: false
})
Object.defineProperty(B.prototype, "foo_B", {
	value: foo,
	enumerable: true,
	configurable: false,
	writtable: false
})
Object.defineProperty(B.prototype, "foo_C", {
	value: foo,
	enumerable: false,
	configurable: true,
	writtable: false
})
Object.defineProperty(B.prototype, "foo_D", {
	value: foo,
	enumerable: false,
	configurable: false,
	writtable: true
})

let b = new B();

Test runner

Ready to run.

Testing in
TestOps/sec
Function
for(let i = 0; i < 100000; ++i)
foo(i)


console.log(A)
ready
Method call
for(let i = 0; i < 100000; ++i)
b.foo(i);
console.log(A)
ready
Method call from proto
for(let i = 0; i < 100000; ++i)
b.__proto__.foo(i);
console.log(A)
ready
Method call from proto + symbol
for(let i = 0; i < 100000; ++i)
b.__proto__[FOO](i);
console.log(A)
ready
Symbol method call
for(let i = 0; i < 100000; ++i)
b[FOO](i);
console.log(A)
ready
Long method name
for(let i = 0; i < 100000; ++i)
b.foofoofoo(i);
console.log(A)
ready
Prop FAA
for(let i = 0; i < 100000; ++i)
b[FAA](i);
console.log(A)
ready
Prop A
for(let i = 0; i < 100000; ++i)
b.foo_A(i);
console.log(A)
ready
Prop B
for(let i = 0; i < 100000; ++i)
b.foo_B(i);
console.log(A)
ready
Prop C
for(let i = 0; i < 100000; ++i)
b.foo_C(i);
console.log(A)
ready
Prop D
for(let i = 0; i < 100000; ++i)
b.foo_D(i);
console.log(A)
ready

Revisions

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