Sorting of an integer array using Quick Sort is the task that was used to collect the statistics. Quick Sort was implemented both sequentially and in parallel. And the elapsed time to sort the array was measured for different array sizes.
In the parallel approach, after breaking down the original array into two sub arrays based on the pivot element, two tasks are created for sorting these two sub arrays and assigned these tasks to the Java Executor Framework. (I used Java Executor Framework for managing threads, because it is not necessary to undertake the burden of creating, synchronizing, managing and terminating the threads manually.)

Following is the summary of the results obtained.
The most intersting observation is the CPU usage graph. I tested this on a dual core machine, hence I get two CPU plots representing each core.For the sequential approach following graph is resulted.

For the parallel approach, following is the graph obtained.

It is quite interesting to see both cores becomes busy at the sametime while resulting with the inproved performance.
Why use single core, leaving others idle.. ? :-)
2 comments: