HTML Preparation code:
AخA
 
1
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.15/lodash.min.js"></script>
Script Preparation code:
x
 
var indexedGroupList = Array.from({length: 50000}, () => {
  var temp_id = Math.floor(Math.random() * 99999999);
  var temp_group_id = Math.floor(Math.random() * 10);
  return {
    "id": temp_id,
    "group_id": temp_group_id,
    "post": {
      "id": temp_id,
      "group_id": temp_group_id,
      "name": "Test Name Here",
      "created_at": 1234871928373,
      "updated_at": 8471829378473,
      "is_test": true,
      "is_valid": false,
      "description": "this is a long form description text here.",
      "description2": "this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.",
      "description3": "this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.",
      "description4": "this is a long form description text here.",
      "description5": "this is a long form description text here.",
      "description6": "this is a long form description text here.",
      "is_test2": true,
      "is_valid2": false,
      "is_test3": true,
      "is_valid3": false,
      "is_test4": true,
      "is_valid4": false
    }
  }
});
var groupList = Array.from({length: 50000}, () => {
  return {
      "id": Math.floor(Math.random() * 99999999),
      "group_id": Math.floor(Math.random() * 10),
      "name": "Test Name Here",
      "created_at": 1234871928373,
      "updated_at": 8471829378473,
      "is_test": true,
      "is_valid": false,
      "description": "this is a long form description text here.",
      "description2": "this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.",
      "description3": "this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.this is a long form description text here.",
      "description4": "this is a long form description text here.",
      "description5": "this is a long form description text here.",
      "description6": "this is a long form description text here.",
      "is_test2": true,
      "is_valid2": false,
      "is_test3": true,
      "is_valid3": false,
      "is_test4": true,
      "is_valid4": false
    }
});
Tests:
  • Filter without index

     
    _.filter(groupList, { 'group_id': 4 });
  • Filter with index

     
    _.filter(indexedGroupList, { 'group_id': 4 });
  • Native filter without index

     
    groupList.filter((item) => item?.group_id == 4);
  • Native filter with index

     
    indexedGroupList.filter((item) => item?.group_id == 4);
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Filter without index
    Filter with index
    Native filter without index
    Native filter with index

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 3 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:95.0) Gecko/20100101 Firefox/95.0
Firefox 95 on Mac OS X 10.15
View result in a separate tab
Test name Executions per second
Filter without index 2305.6 Ops/sec
Filter with index 2601.7 Ops/sec
Native filter without index 2621.4 Ops/sec
Native filter with index 2919.3 Ops/sec