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; Ubuntu; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0
Browser:
Firefox 125
Operating system:
Ubuntu
Device Platform:
Desktop
Date tested:
one year ago
Test name
Executions per second
Proxy method
5841365.5 Ops/sec
Replaced method
4063181.5 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") } }