Back in June of 1989 I wrote some programs for the QL in three different languages (Forth, Pascal, and SUPERBASIC) to illustrate differing speed obtained by a threaded/interpreted language, a complied language, and our standard QL interpreted language (see 9/89 and 1/90 CATS NL). The program was a 17-line program (Superbasic version) that would determine prime numbers less than 32767, and would stop at any value entered by the user. Herb Schaaf went off to a class on “C” programming and converted my code to “C” (with his improvements, of course – see 7/90 CATS NL). With his source code in “C” he had the opportunity compile the program and test it on the QL and a bunch of computers, from the QL (in its native mode and emulating an MS-DOS machine) up to a DEC VAX-8650, and even a Cray Supercomputer. Run-times varied from approximately 0.001 seconds to 2070 seconds to count all positive primes less than 32767.
I now have made some more comparisons for this program. First, I obtained two of the compilers for QL Superbasic (QL Liberator, and Turbo-Charge) and compiled the SuperBasic code with each compiler. Although the Liberator compiled the code just fine, Turbo-Charge didn’t manage to compile it until I improved the code to take care of a poor FOR – NEXT loop. Anyway, the run-times to count primes from 32K to 29000 are as shown below:
seconds SUPERBASIC(intepreted) 245 Liberator 53 Turbo-Charge 40
Therefore, we can speed up this simple program by 4.6 to 6.1 times with the respective compilers. Herb and I also reported that Pascal (Metacomco) and “C” (Small-C) compliers produce programs from appropriate source code that will perform this task in 27 and 16 seconds, respectively.
Interesting? I obtained a “no-name” “286” IBM clone with CPU speeds that could be set to 6 Mhz or 12 Mhz (0 wait states) last February. Therefore, I could make some more comparisons. I converted the SUPERBASIC version to GW Basic, and I converted the QL Forth program to run on the IBM-clone with the use of a public domain Forth kernel (Laxen & Perry’s F83, April 1984). To go to the same 29000 limit the times (seconds) were:
QL IBM-clone
6 Mhz 12 Mhz
Forth 23 No Data 11.5
Basic 245 118 57
Since these language interpretaiton systems have all sorts of differences, I am sure that we can not ascribe these time differences to any particular factor.
We can still look at the “C” version of the program – Herb was kind enough to send me the compiled MS-DOS code, obtained by three different techniques. One was was compiled with Turbo-C on an IBM PS/2 Model 30 (a “286” machine), one with Turbo-C and the QL with the Conqueror MS-DOS emulator, the third was compiled with the latter combination, but with MIX-C. All of these counted the primes down to 29000 in 2.0 seconds, at 12 Mhz and in 3.5 to 3.9 seconds at 6 Mhz on my IBM-clone. For a more complete comparison, I determined the run-times to determine all positive prime numbers below 32K. The results, including Herb’s earlier values, were:
seconds
DEC VAX-8650 0.2
My IBM-clone, 12 Mhz(either) 16
Toshiba T5200/100 (Turbo-C) 22
My IBM-clone, 6 Mhz(either) 31
IBM PS/2, Mdl 30 (Mix-C) 42
IBM PS/2, Mdl 30 (Turbo-C) 55
QL & Conqueror emulator
(Mix-C) 1390
(Turbo-C) 2070
Thses results seem to show that the Conqueror runs about 33 to 86 times slower than the computers that it emulates. I also find that it is curious that the Toshiba and “no-name” computers run this program slower than IBM’s PS/2 that uses the same 80286 micro processer.