Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Wrapping objects method removal performance
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
Browser:
Chrome 124
Operating system:
Linux
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Proxy method
1991505.1 Ops/sec
Replaced method
1564878.1 Ops/sec
Script Preparation code:
class Parent { next = null constructor(next) { this.next = next } foo() { return "Parent" } optimize() { this.next?.optimize() } } class Wrapper extends Parent { foo() { return this.next.foo() } optimize() { this.next.optimize() this.foo = this.next.foo } } class Unwrappable extends Parent { foo() { return this.next.foo() } } class Child1 extends Parent { foo() { return "Child1" } } class Child2 extends Parent { foo() { return "Child2" } } var a = new Wrapper(new Unwrappable(new Wrapper(new Wrapper(new Unwrappable(new Wrapper(new Child2())))))) var b = new Wrapper(new Unwrappable(new Wrapper(new Wrapper(new Unwrappable(new Wrapper(new Child1())))))) b.optimize()
Tests:
Proxy method
for (let i = 0; i < 10; ++i) { if (a.foo() !== "Child2") { throw new Error("Unexpected result") } }
Replaced method
for (let i = 0; i < 10; ++i) { if (b.foo() !== "Child1") { throw new Error("Unexpected result") } }