withoutVsFilter

JavaScript performance comparison

Revision 2 of this test case created

Preparation code

<script src='http://underscorejs.org/underscore.js'>
</script>
<script>
Benchmark.prototype.setup = function() {
    var testArr=[];
    for(var i=0;i<10000;i++){
        testArr.push({id:i, description: "testing, big text " + 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
without
_.without(testArr,{id:9999, description: "testing, big text 9999"})
pending…
filter
testArr.filter(function(element){
return element.id===9999;
})
pending…
array
var temp=[];
for(var i=0;i<testArr.length;i++){
if(testArr[i].id !== 9999){
temp.push(testArr[i]);
}
}

testArr=temp;
pending…
splice method
for(var i=0;i<testArr.length;i++)
{
   if(testArr[i].id===9999) {
    testArr.splice(i,1);
    break;
  }
}
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