anonymouse function optimisation

JavaScript performance comparison

Test case created by whitneyit

Preparation code

<script type="text/javascript">
        var aaa = ( function () {

                        var arr = [],
                                index = 0,
                                length = 1000;

                        for ( ; index < length; index++ ) {
                                arr.push( index );
                        }

                        return function aaa ( loc ) {
                                return arr.indexOf( loc );
                        };

                })(),

                bbb = function bbb ( loc ) {

                        var arr = [],
                                index = 0,
                                length = 1000;

                        for ( ; index < length; index++ ) {
                                arr.push( index );
                        }

                        return arr.indexOf( loc );

                };
</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
cached
aaa( 999 );
pending…
not cached
bbb( 999 );
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