jsPerf.app is an online JavaScript performance benchmark test runner & jsperf.com mirror. It is a complete rewrite in homage to the once excellent jsperf.com now with hopefully a more modern & maintainable codebase.
jsperf.com URLs are mirrored at the same path, e.g:
https://jsperf.com/negative-modulo/2
Can be accessed at:
https://jsperf.app/negative-modulo/2
create many objects vs creating many class instances
class Apa {
#_name;
#_age;
#_id;
constructor(name, age) {
this.#_name = name;
this.#_age = age;
this.#_id = `Apa/${name}/${age}`;
}
get name() {
return this.#_name;
}
get age() {
return this.#_age;
}
get id() {
return this.#_id;
}
}
class Apa2 {
_name;
_age;
_id;
constructor(name, age) {
this._name = name;
this._age = age;
this._id = `Apa/${name}/${age}`;
}
get name() {
return this._name;
}
get age() {
return this._age;
}
get id() {
return this._id;
}
}
function apa(name, age) {
return {
name,
age,
id: `Apa/${name}/${age}`,
};
}
const itemsCount = {
"10k": 10e+3,
"100k": 100e+3,
"1M": 1e+6,
"10M": 10e+6,
};
function loop(times, fn) {
for (let idx=0; idx<times; ++idx) {
fn();
}
}
Ready to run.
Test | Ops/sec | |
---|---|---|
10k instances |
| ready |
10k objects |
| ready |
10k instances (public props) |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.