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
class VectorArray {
data = new Float32Array(2)
dimension = 2
get x() { return this.data[0] }
set x(value) { this.data[0] = value }
get y() { return this.data[1] }
set y(value) { this.data[1] = value }
/** @param {number} scalar */
mul(scalar) {
for (let i = 0; i < this.dimension; i++) {
this.data[i] *= scalar
}
return this
}
/** @param {VFXVector} other */
add(other) {
for (let i = 0; i < this.dimension; i++) {
this.data[i] += other.data[i]
}
return this
}
/** @param {VFXVector} other */
sub(other) {
for (let i = 0; i < this.dimension; i++) {
this.data[i] -= other.data[i]
}
return this
}
constructor(x, y) {
this.data[0] = x
this.data[1] = y
}
}
class VectorArrayDestructoring {
data
dimension = 2
get x() { return this.data[0] }
set x(value) { this.data[0] = value }
get y() { return this.data[1] }
set y(value) { this.data[1] = value }
/** @param {number} scalar */
mul(scalar) {
for (let i = 0; i < this.dimension; i++) {
this.data[i] *= scalar
}
return this
}
/** @param {VFXVector} other */
add(other) {
for (let i = 0; i < this.dimension; i++) {
this.data[i] += other.data[i]
}
return this
}
/** @param {VFXVector} other */
sub(other) {
for (let i = 0; i < this.dimension; i++) {
this.data[i] -= other.data[i]
}
return this
}
constructor(...data) {
this.data = new Float32Array(data)
}
}
class VectorProperties {
x; y;
/** @param {number} scalar */
mul(scalar) {
this.x *= scalar
this.y *= scalar
return this
}
/** @param {VFXVector} other */
add(other) {
this.x += other.x
this.y += other.y
return this
}
/** @param {VFXVector} other */
sub(other) {
this.x -= other.x
this.y -= other.y
return this
}
constructor(x, y) {
this.x = x
this.y = y
}
}Ready to run.
| Test | Ops/sec | |
|---|---|---|
| with float32 storage | | ready |
| with float32 storage and destructoring | | ready |
| with property storage | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.