GlMatrix symmetric round() branchless

Benchmark created on


Description

Branchless version of glMatrix.round().

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

function randnum() {
	return Math.random() * 100;
}

Test runner

Ready to run.

Testing in
TestOps/sec
old round()
for (let i = 0; i < 100; i++) {
	let n = glMatrix.glMatrix.round(randnum());
}
ready
new round()
for (let i = 0; i < 100; i++) {
	let n = glMatrixUpdate.glMatrix.round(randnum());
}
ready

Revisions

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