Combining and sorting arrays: sorted vs unsorted

Benchmark created on


Setup

function mergeAndSort(arr1, arr2){
  return arr1.concat(arr2).sort()
}

Test runner

Ready to run.

Testing in
TestOps/sec
Combine & sort unsorted arrays
mergeAndSort(
[80,88,73,108,90,106,60,70,61,85,72,75,89,86,81,71,103,66,104,100,87,63,96,82,105,76,78,84,93,99,94,92,97,101,67,77,79,91,107,74,69,64,95,102,68,62,65,83,98,109],
[41,49,34,18,32,2,1,12,42,46,15,29,47,19,27,25,23,39,36,48,11,7,16,13,6,37,38,43,33,0,22,35,9,14,44,31,8,26,21,17,24,5,30,20,40,10,45,28,3,4]
)
ready
Combine & sort pre-sorted arrays
mergeAndSort(
[60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109],
[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49]
)
ready

Revisions

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