Inlined vs global inclusion filtering

Benchmark created on


Setup

const arrayToFilter = Array(10000).fill(0).map((_, index) => String.fromCharCode(index % 26 + 65));

Test runner

Ready to run.

Testing in
TestOps/sec
Inline case
const filteredArray = arrayToFilter.filter((char) => ['A', 'B', 'C'].includes(char));
ready
Non inline case
const WHITE_LIST = ['A', 'B', 'C'];

const filteredArray = arrayToFilter.filter((char) => WHITE_LIST.includes(char));
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.