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
Tests if it is more efficient to compare the existing value of a 4x4 matrix with an incoming value and update it if they differ or to just update it.
<canvas id="test"></canvas>
const canvas = document.querySelector("canvas#test");
const gl = canvas.getContext("webgl2");
const vss = `\
#version 300 es
uniform mat4 u_matrix;
void main() {
gl_Position = u_matrix * vec4(0, 0, 0, 1);
}
`;
const fss = `\
#version 300 es
precision mediump float;
out vec4 outColor;
void main() {
outColor = vec4(0, 0, 0, 1);
}
`;
function makeShader(src, type) {
const out = gl.createShader(type);
gl.shaderSource(out, src);
gl.compileShader(out);
if (!gl.getShaderParameter(out, gl.COMPILE_STATUS)) {
throw new Error(gl.getShaderInfoLog(out));
}
return out;
}
const vs = makeShader(vss, gl.VERTEX_SHADER);
const fs = makeShader(fss, gl.FRAGMENT_SHADER);
const program = gl.createProgram();
gl.attachShader(program, vs);
gl.attachShader(program, fs);
gl.linkProgram(program);
gl.deleteShader(vs);
gl.deleteShader(fs);
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
throw new Error(gl.getProgramInfoLog(program));
}
const matLoc = gl.getUniformLocation(program, "u_matrix");
const matrix = new Float32Array([
0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15
]);
gl.useProgram(program);
const [j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15] = [...matrix];
gl.uniformMatrix4fv(matLoc, false, matrix);
let matrixValueCache = [j0, j1, j2, j3, j4, j5, j6, j7, j8, j9, j10, j11, j12, j13, j14, j15];
gl.deleteProgram(program);
Ready to run.
Test | Ops/sec | |
---|---|---|
Re-Set without Check |
| ready |
Set if Not Equivalent with Cached Value |
| ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.