Heap Sort - Performance

This section provides a tutorial on how to measure the performance of the Heap Sort algorithm. My first Java implementation of Heap Sort is performing somewhere between O(N*Log2(N) and O(N*N) order levels.

Now let's see how my Java implementation of the Heap Sort algorithm performs. Here are the results with my SortTest.java class and HyArrays.heapSort() function using JDK 13.

Array size: 100000
Average sorting time: 34 milliseconds
Number of tests: 1000
Performance: 0.34 O(N) microseconds
Performance: 0.02047003970515072 O(N*Log2(N)) microseconds
Performance: 3.4E-6 O(N*N) microseconds

Array size: 200000
Average sorting time: 89 milliseconds
Number of tests: 1000
Performance: 0.445 O(N) microseconds
Performance: 0.0252702490233113 O(N*Log2(N)) microseconds
Performance: 2.225E-6 O(N*N) microseconds

Array size: 300000
Average sorting time: 168 milliseconds
Number of tests: 1000
Performance: 0.56 O(N) microseconds
Performance: 0.030778357778105794 O(N*Log2(N)) microseconds
Performance: 1.8666666666666667E-6 O(N*N) microseconds

As a reference, results from an older computer are listed below:

Array size: 10000
Average sorting time: 29 milliseconds
Number of tests: 1000
Performance: 2.9 O(N) microseconds
Performance: 0.21824674685638637 O(N*Log2(N)) microseconds
Performance: 2.9E-4 O(N*N) microseconds

Array size: 20000
Average sorting time: 76 milliseconds
Number of tests: 1000
Performance: 3.8 O(N) microseconds
Performance: 0.2659628006957283 O(N*Log2(N)) microseconds
Performance: 1.9E-4 O(N*N) microseconds

Array size: 30000
Average sorting time: 134 milliseconds
Number of tests: 1000
Performance: 4.466666666666667 O(N) microseconds
Performance: 0.30032705633819357 O(N*Log2(N)) microseconds
Performance: 1.488888888888889E-4 O(N*N) microseconds

Table of Contents

 About This Book

 Introduction of Sorting Algorithms

 Java API for Sorting Algorithms

 Insertion Sort Algorithm and Java Implementation

 Selection Sort Algorithm and Java Implementation

 Bubble Sort Algorithm and Java Implementation

 Quicksort Algorithm and Java Implementation

 Merge Sort Algorithm and Java Implementation

Heap Sort Algorithm and Java Implementation

 Heap Sort - Algorithm Introduction

 Heap Sort - Java Implementation

Heap Sort - Performance

 Heap Sort - Implementation Improvements

 Shell Sort Algorithm and Java Implementation

 Sorting Algorithms Implementations in PHP

 Sorting Algorithms Implementations in Perl

 Sorting Algorithms Implementations in Python

 Performance Summary of All Implementations

 References

 Full Version in PDF/EPUB