JS Challenge 3

JavaScript performance comparison

Test case created and last updated

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var r = 'Hello6 9World 2, Nic8e D7ay!';
};
</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
test
NumberSearch(r);

function NumberSearch(str){
                var letter = str.replace(/[0-9\.,-\/#!$%\^&\*;:{}=\-_`~() ]/g,"");
                var number = str.replace(/[a-zA-Z\.,-\/#!$%\^&\*;:{}=\-_`~() ]/g,"");
                var n = 0;

                for (var i=0; i< number.length; i++)
                {
                        n = n + parseInt(number[i]);
                }

                var result = Math.round(n / letter.length);
                return result;
        }
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