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
Here we will explore the speed of looping through a flattened typed array vs an array of Objects with polymorphic key types (AKA, a standard POJO)
var Particle = function() {
if (!(this instanceof Particle)) return new Particle
this.x = 1.0
this.y = 2.0
}
var count = 200000
var particlesPOJO = []
var particlesTyped = new Float32Array(count * 2)
for (var i = 0; i < count; ++i) {
particlesPOJO.push(Particle())
}
for (var i = 0; i < count; i += 2) {
particlesTyped[i] = 1.0
particlesTyped[i + 1] = 2.0
}
Ready to run.
Test | Ops/sec | |
---|---|---|
array of POJOs |
| ready |
typed array |
| ready |
for in array of POJOs |
| ready |
for in type array |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.