Hardcoded vs called Statement

JavaScript performance comparison

Test case created by Hekat

Preparation code

<script type="text/javascript">
       
        function lerp ( a, b, t )
        {
                return a + t * ( b - a );
        }
       
        var ns = {};
       
        ns.lerp = function ( a, b, t )
        {
                return a + t * ( b - a );
        };
       
        var     a = Math.random() * 20.0 - 10.0,
                b = Math.random() * 20.0 - 10.0,
                t = Math.random(),
                f = 0.0;
               
</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
Cas du traitement "hardcodé"
f = a + t * ( b - a );
pending…
Cas du traitement appelé
f = lerp( a, b, t );
pending…
Cas du traitement appelé depuis un espace de nom
f = ns.lerp( a, b, t );
pending…

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

Compare results of other browsers

0 comments

Add a comment