breaking up arrays test

JavaScript performance comparison

Revision 3 of this test case created by Asavi

Info

Testing alternative to native filtering.

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var master = [
        {
            name: "joawhjd",
            something: 125,
            andanother: "wgha"
        },
        {
            name: "nawgw",
            something: 65,
            andanother: "wgha"
        },
        {
            name: "jawdu",
            something: 32,
            andanother: "wgha"
        },
        {
            name: "pfdafg",
            something: 46,
            andanother: "wgha"
        },
        {
            name: "mwaag",
            something: 88,
            andanother: "wgha"
        },
        {
            name: "bawdj",
            something: 75,
            andanother: "wgha"
        },
        {
            name: "lkja",
            something: 4,
            andanother: "wgha"
        },
        {
            name: "jsaaw",
            something: 52,
            andanother: "wgha"
        },
        {
            name: "gasda",
            something: 12,
            andanother: "wgha"
        },
        {
            name: "hawda",
            something: 15,
            andanother: "wgha"
        },
        {
            name: "dawdd",
            something: 21,
            andanother: "wgha"
        }
    ]
   
    Array.prototype.filtery = function (index, value){
        for(var i=0,j=this.length; i<j; i++){
            if(this[i][index] === value) return this[i];
        }
    };
   
};
</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
filter master
master.filter(function(e){
    return e.name === "dawdd";
})
pending…
indexof child
master.filtery("name","dawdd");
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