We implemented the test programs in Pascal first and ported them to C and Oberon, preserving the structure as good as we could. The compilers tested were MPW Pascal, MPW C, MPW Oberon, and MacOberon. MPW Pascal and MPW C are commercial products. The latter two work with intermediate code and supposedly employ elaborate optimizations to reduce code size and execution speed. We measured on a Macintosh Quadra 700 equipped with a 25 MHz MC 68040 and 8 MBytes of RAM. Table 1 shows the time consumed averaged over five executions of the respective programs.
MPW Oberon generates the fastest code on average. The fact that MPW Oberon is even faster than MPW C came as a genuine surprise, after all MPW C is a sophisticated optimizing compiler in its third version. MacOberon, the second Oberon compiler in our test series, produces equally good code as the C compiler, proving that a good programming language can be as efficient as C (against popular belief!). Analysis of the object code revealed that C wins in the first three categories because it uses register variables. The two Oberon compilers are not taking advantage of register variables.
| MPW Pascal | MPW C | MPW Oberon | MacOberon | |
|---|---|---|---|---|
| Powers | 375 | 246 | 411 | 788 |
| Heuristic | 2089 | 1765 | 1795 | 1854 |
| Primes | 914 | 576 | 1003 | 991 |
| Integrate | 4952 | 5442 | 3964 | 4087 |
| KnightsTour | 7826 | 4705 | 4248 | 4867 |
| Marriage | 1714 | 2075 | 1970 | 2157 |
| Selection | 2313 | 481 | 355 | 421 |
| Bubble | 3809 | 2759 | 2457 | 3889 |
| Hanoi | 2584 | 4193 | 2201 | 2160 |
| Quicksort | 2998 | 2092 | 2357 | 2598 |
| Queens | 5489 | 8046 | 5380 | 4743 |
| IMatMult | 249 | 290 | 181 | 222 |
| RMatMult | 266 | 312 | 183 | 226 |
| Rating | 39 | 34 | 23 | 34
|
| MPW Pascal | MPW C | MPW Oberon | MacOberon | |
|---|---|---|---|---|
| Powers | 992 | 1614 | 102 | 590 |
| Heuristic | 1042 | 1800 | 218 | 633 |
| Primes | 1406 | 1484 | 168 | 636 |
| Integrate | 1018 | 1340 | 212 | 640 |
| KnightsTour | 1044 | 1998 | 214 | 647 |
| Marriage | 1556 | 2160 | 188 | 660 |
| Selection | 1022 | 1236 | 210 | 586 |
| Bubble | 1422 | 1400 | 162 | 529 |
| Hanoi | 938 | 1432 | 170 | 653 |
| Quicksort | 1492 | 1682 | 198 | 553 |
| Queens | 1088 | 2234 | 202 | 569 |
| IMatMult | 1210 | 1704 | 200 | 660 |
| RMatMult | 1216 | 1456 | 180 | 633 |
| Rating | 40 | 51 | 13 | 26 |
| MPW Pascal | MPW C | MPW Oberon | MacOberon | |
|---|---|---|---|---|
| Powers | 392 | 288 | 434 | 528 |
| Heuristic | 412 | 402 | 470 | 538 |
| Primes | 322 | 246 | 374 | 424 |
| Integrate | 898 | 744 | 722 | 802 |
| KnightsTour | 583 | 394 | 614 | 704 |
| Marriage | 1086 | 730 | 1594 | 2176 |
| Selection | 544 | 370 | 562 | 718 |
| Bubble | 326 | 290 | 244 | 384 |
| Hanoi | 152 | 148 | 132 | 180 |
| Quicksort | 344 | 280 | 318 | 458 |
| Queens | 452 | 424 | 474 | 572 |
| IMatMult | 572 | 452 | 476 | 598 |
| RMatMult | 604 | 488 | 504 | 626 |
| Rating | 33 | 16 | 30 | 51
|