test121212

Benchmark created on


Preparation HTML

<script>
function inc(arr1, arr2) {
  const arr3 = arr2.map(item => item.id);
  let result = arr1.filter(item => !arr3.includes(item))
  return result
}

function set(arr1, arr2) {
  const set = new Set(arr2.map(item => item.id));
  let result = arr1.filter(item => !set.has(item))
  return result
}
</script>

Setup

const getRandomArr = len => Array.from({ length: len }).map(() => Math.ceil(Math.random * 1e6))

var arrLen = 15
var arr1 = getRandomArr(arrLen)
var arr2 = getRandomArr(arrLen)

Test runner

Ready to run.

Testing in
TestOps/sec
inc
inc(arr1, arr2)
ready
set
set(arr1, arr2)
ready

Revisions

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