Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
Feature Requests
FAQ
Register
Log In
Run results for:
this vs super in inheritance
compare the speed of "super" vs "this" in the subclass
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36 Edg/132.0.0.0
Browser:
Chrome 132
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
Benchmark engine:
Benchmark.js
usingThisVariables
177.2M/s
usingThis
169.6M/s
usingSuperVariable
162.3M/s
usingSuper
141.9M/s
View exact numbers
Test name
Executions per second
✓
usingThisVariables
177,198,720 Ops/sec
usingThis
169,573,648 Ops/sec
usingSuperVariable
162,338,544 Ops/sec
usingSuper
141,940,240 Ops/sec
Script Preparation code:
var Animal = class Animal { constructor(sound, name) { this.sound = sound; this.name = name; } getMessage() { return 1337; } } var Dog = class Dog extends Animal { constructor() { super('woof', 'dog'); this.legs = 4 } // hard coded values usingThis() { this.getMessage(); } usingSuper() { super.getMessage(); } // class variables usingThisVariables() { return this.sound; } usingSuperVariable() { return super.sound; } } var animal = new Animal('meow', 'cat'); var dog = new Dog();
Tests:
usingThis
const foo = dog.usingThis();
usingSuper
const foo = dog.usingSuper();
usingThisVariables
const foo = dog.usingThisVariables();
usingSuperVariable
const foo = dog.usingSuperVariable();