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
TypedArray, Float32Array, Object, Class access time read time write time
<span></span>
let span = document.body.querySelector("span");
let oVectors = [];
let vVectors = [];
let fVectors = [];
let cVectors = [];
function Vector (x, y) {
this.x = x;
this.y = y;
}
class Vector32 extends Float32Array {
constructor (x, y) {
super (2);
this[0] = x;
this[1] = y;
}
get x () { return this[0]; }
get y () { return this[1]; }
}
COUNT = 100000;
for (let i = 0; i < COUNT; i++ ) {
const x = 10000 * (Math.random() - 0.5);
const y = 10000 * (Math.random() - 0.5);
const f = new Float32Array(2);
f[0] = x;
f[1] = y;
oVectors.push({ x , y });
vVectors.push(new Vector(x, y));
fVectors.push(f);
cVectors.push(new Vector32(x, y));
}
let acc = 0;
span.innerText = acc;
Ready to run.
Test | Ops/sec | |
---|---|---|
Vector GET |
| ready |
Vector SET |
| ready |
Float32Array GET |
| ready |
Float32Array SET |
| ready |
Vector32 GET ELEMENT |
| ready |
Vector32 SET ELEMENT |
| ready |
Vector32 GET GETTER |
| ready |
Vector32 SET GETTER |
| ready |
POJO GET |
| ready |
POJO SET |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.