Ackermann Function
Fibonacci Sequence
Heapsort Function
Hello World
List Operations
Random Number Generator

Heapsort Function

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.

Test Goal

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.


Language Milliseconds Weighted Characters
gcc 2.95.4 7 1065
gcj 3.3.2 66 1265
Python 2.3.2 398 772
MzScheme 203 415 1481
Perl 5.8.0 543 1087
Tcl 8.4.5 573 1188
Ruby 1.7.2 1112 753
PHP 4.2.3 1479 1031

Last updated: Sun Jan 18 11:15:31 CET 2004


gcc 2.95.4
gcj 3.3.2
mzscheme 203
perl 5.8.0
php 4.2.3
python 2.3.2
ruby 1.7.2
tcl 8.4.5