This test implements an in-place heap sort function that takes arguments (N, ARY), where N is the number of elements in the array ARY, starting from index 1. ARY is passed by reference. We use the heapsort algorithm from Numerical Recipes in C, section 9.2, page 247. The values that are sorted are randomly generated double-precision floating point numbers. We use the same naive (and lightweight) pseudo-random number generator used in the Random Number Generator test.
The goal is to measure the languages's speed with algorithmical code that has to deal with array access, counters, loops and comparisons: many classical computer science algorithms perform these kinds of operations. Even with scripting languages, it is often needed to resort to this kind of programming, as long as non-trivial algorithms are often missing from the standard library so it can be useful to have an implementation in the language itself. More generally, there is no way to avoid algorithmical code in non trivial applications even if the standard library is quite big.
Input argument meaning
The input argument specifies the array length to generate and sort.
Last updated: Sun Jan 18 11:15:31 CET 2004