Custom sorting algorithm performance (vs Arrays.sort() and parallelSort())

I implemented a basic sorting algorithm in Java, and compared its performance to those of native methods (Arrays.sort() and Arrays.parallelSort()). The program is as follows.

public static void main(String[] args) {

// Randomly populate array

int[] array = new int[999999];

for (int i = 0; i < 999999; i++)

array[i] = (int)Math.ceil(Math.random() * 100);

long start, end;

start = System.currentTimeMillis();

Arrays.sort(array);

end = System.currentTimeMillis();

System.out.println("======= Arrays.sort: done in " + (end - start) + " ms ========");

start = System.currentTimeMillis();

Arrays.parallelSort(array);

end = System.currentTimeMillis();

System.out.println("======= Arrays.parallelSort: done in " + (end - start) + " ms ========");

start = System.currentTimeMillis();

orderArray(array);

end = System.currentTimeMillis();

System.out.println("======= My way: done...

Read More »

By: StackOverFlow - 5 days ago

Related Posts