HTML Preparation code:
AخA
 
1
<!--your preparation HTML code goes here-->
Script Preparation code:
x
 
function generateTestData(size) {
    const items = Array.from({
        length: size
    }, (_, i) => ({
        id: i,
        name: `Item ${i}`
    }));
    // Randomly select ~75% of items
    const selectedItems = items
        .filter(() => Math.random() > 0.25)
        .map(item => item.id);
    return {
        bill: {
            items
        },
        selectedItems
    };
}
const dataSizes = [100, 1000, 10000, 100000, 1000000];
var data = generateTestData(Math.floor(Math.random() * 5));
var bill = data.bill;
var selectedItems = data.selectedItems;
Tests:
  • Array.every Array.includes

     
    const allSelected = bill.items.every(({ id }) => selectedItems.includes(id));
    return allSelected;
  • Array.every Set.has with Set creation

     
    const allSelected = ((selected) => 
              bill.items.every(({ id }) => selected.has(id))
            )(new Set(selectedItems));
    return allSelected;
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    Array.every Array.includes
    Array.every Set.has with Set creation

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 21 days ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Chrome 133 on Mac OS X 10.15.7
View result in a separate tab
Test name Executions per second
Array.every Array.includes 102695384.0 Ops/sec
Array.every Set.has with Set creation 32997224.0 Ops/sec