array filtering

JavaScript performance comparison

Test case created

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var data = [];
    for(var j = 0; j < 10000; j++)
    {
        var id = 7 + j%2;
        data.push({"id":1,"id_parent":id,"name":"sub category of cat 7-1"});
    }
};
</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
loop
var filteredResults = [];
for (var i = 0, l = data.length; i < l; i++) {
  if (data[i].id_parent === 7) {
    filteredResults.push(data[i]);
  }
}
pending…
filter
var filteredResults = data.filter(function(item) {
  return item.id_parent === 7;
});
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