Improve on vec4.random() in gl-matrix

JavaScript performance comparison

Test case created

Info

This is my first attempt to improve on vec4.random()...

Sample data here: http://jsfiddle.net/WV8kZ/

Preparation code

<script src="https://rawgithub.com/toji/gl-matrix/master/dist/gl-matrix-min.js"></script>
<script>
Benchmark.prototype.setup = function() {
    var scale = 13.333;
   
    var out = vec4.create();
   
    vec4.randomTest = function (out, scale) {
        scale = scale || 1;
        out[0] = Math.random();
        out[1] = Math.random();
        out[2] = Math.random();
        out[3] = Math.random();
        var adjust = scale / vec4.length(out);
        out[0] *= adjust;
        out[1] *= adjust;
        out[2] *= adjust;
        out[3] *= adjust;
        return out;
    };
   
};
</script>

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
vec4.random
vec4.random(out, scale);
pending…
vec4.randomTest
vec4.randomTest(out, scale);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment