Example perf on smaller arrays (v4)

Revision 4 of this benchmark created on


Setup

const data = [...Array(300).fill().map((el, i) => ({name: `item ${i}`, isHighlighted: undefined}))]

Test runner

Ready to run.

Testing in
TestOps/sec
Sort
data.sort((a, b) => {
      if (a.isHighlighted == b.isHighlighted) return 0
      return a.isHighlighted ? -1 : 1
    })
ready
Concat
data.filter((el) => el.isHighlighted)
    .concat(
      data
        .filter((el) => !el.isHighlighted),
    )
ready

Revisions

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