GlMatrix transpose() branchless

Benchmark created on


Description

Transpose matrices without checking if the matrix is self-modifying.

Preparation HTML

<!-- GLMatrix Update -->
<script src="https://rawcdn.githack.com/solarunes/gl-matrix/771dfba6e47e6ac001bc3e6152d4c1c86a268e52/dist/gl-matrix-min.js"></script>

<script>
window.glMatrixUpdate = glMatrix;
delete glMatrix;
</script>

<!-- GLMatrix v3.4.4 (release) -->
<script src="https://cdn.jsdelivr.net/npm/gl-matrix@3.4.4/gl-matrix-min.min.js"></script>

Setup

// random matrix
function randm(size) {
	return new Float32Array(size).map(el => el = Math.random() * 100);
}

Test runner

Ready to run.

Testing in
TestOps/sec
old mat3.transpose()
for (let i = 0; i < 100; i++) {
	let a = randm(9);
	let aT = randm(9);
	glMatrix.mat3.transpose(aT, a);
}
ready
new mat3.transpose()
for (let i = 0; i < 100; i++) {
	let a = randm(9)
	let aT = randm(9);
	glMatrixUpdate.mat3.transpose(aT, a);
}
ready
old mat4.transpose()
for (let i = 0; i < 100; i++) {
	let a = randm(16);
	let aT = randm(16);
	glMatrixUpdate.mat4.transpose(aT, a);
}
ready
new mat4.transpose()
for (let i = 0; i < 100; i++) {
	let a = randm(16);
	let aT = randm(16);
	glMatrixUpdate.mat4.transpose(aT, a);
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.