`s1` Calculator

Benchmark created on


Description

The method used to calculate s1 in glMatrix and μMath.

Test runner

Ready to run.

Testing in
TestOps/sec
glMatrix Solution
var v1, v2, s1;
do {
	v1 = Math.random() * 2 - 1;
	v2 = Math.random() * 2 - 1;
	s1 = v1 * v1 + v2 * v2;
} while(s1 >= 1);
ready
μMath Solution
const a = Math.random();
const v1 = a * 2 - 1;
const v2 = (4 * Math.random() - 2) * Math.sqrt(a * -a + a);
const s1 = v1 * v1 + v2 * v2;
ready

Revisions

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