Generate a pseudorandom number between 0 and 1 - Math.sin() vs 2 * Math.PI division (v3)

Revision 3 of this benchmark created on


Description

For John von Neumann, H. and K.

Test runner

Ready to run.

Testing in
TestOps/sec
Math.sin()
let seed = 1;
function random() {
    let x = Math.sin(seed++) * 10000;
    return x - Math.floor(x);
}
ready
2 * Math.PI
let seed = 1;
function random() {
    let x = seed++ / (2* Math.PI);
    return x - Math.floor(x);
}
ready
Math.PI
let seed = 1;
function random() {
    let x = seed++ / (Math.PI);
    return x - Math.floor(x);
}
ready

Revisions

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