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
"use strict";
const N = 10000
const AoSoA_SPLIT = 8
const i = Math.round( Math.random() )
class point3D {
constructor (x, y, z) {
this.x = x
this.y = y
this.z = z
}
}
// AoS
const AoS_points = Array( N ).fill().map( e =>
new point3D(
Math.random(),
Math.random(),
Math.random()
)
)
const AoS_get_point_x = i => AoS_points[i].x
// SoA
const SoA_points = new point3D(
Array( N ).fill().map( e => Math.random() ),
Array( N ).fill().map( e => Math.random() ),
Array( N ).fill().map( e => Math.random() )
)
const SoA_get_point_x = i => SoA_points.x[i]
// AoSoA
const AoSoA_points = Array( Math.ceil( ( N + AoSoA_SPLIT - 1 ) / AoSoA_SPLIT ) ).fill().map( e =>
new point3D(
Array( AoSoA_SPLIT ).fill().map( e => Math.random() ),
Array( AoSoA_SPLIT ).fill().map( e => Math.random() ),
Array( AoSoA_SPLIT ).fill().map( e => Math.random() )
)
)
const AoSoA_get_point_x = i => AoSoA_points[Math.floor( i / AoSoA_SPLIT )].x[i % AoSoA_SPLIT]
Ready to run.
Test | Ops/sec | |
---|---|---|
Array of structures |
| ready |
Structure of arrays |
| ready |
Array of structures of arrays |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.