Duane Parker had the time down to 23 seconds using Forth in his January classic on benchmarking with Pascal, QL-SuperBasic, etc.
The Small-C QL combo does it in 16 seconds( 14 with Lightning installed). An IBM PS/2-30 and the same (well, nearly the same) source code using Turbo-C took 6 seconds. Mix-C & IBM did it in 5. A Toshiba T5200/100 & Turbo-C took 2 seconds.
When ported over to the VAX-8650 and timed it came back as 0.0 seconds, so I extended the run down to 1; then it took 0.2 seconds. Times to go down to 1 are:
Turbo-C & T5200 22 secs. Mix-C & IBM 42 Turbo-C & IBM 55 Small-C & QL 155 with QL & Conqueror Mix-C 1390 Turbo-C 2070
Now as to costs:
Hardware---- QL systems $$ hundreds IBM systems $ thousands T5200 $ ten thousand VAX $$hundreds of Thousands Software---- Small-C $ 1 (cost of disk) Mix-C $ 20 (BEST BUY!!) Turbo-C $ 100 (discount) UNIX C $ a lot more
/* dpbench7_c May 13 1990 10:30am
** Small-C benchmark program by Duane H. Parker
** Ref: CATS Newsletter Jan 1990 pages 6-8.
*/
#include <stdio_h> /* standard input/output header */
#define MAX 32767 /* limit of signed integers */
main()
{
char c, string[20]; /* characters and/or strings */
int start, stop, index, i, j; /* handy integer values */
int testfactor, tfsq; /* testfactor and its square */
int secs, d1[2], d2[2]; /* used in timing */
int minval, pos; /* more integers */
minval = 0;
pos = (MAX/100);
testfactor = 181; /* int(sqrt(MAX)) */
tfsq = 32761;
while( ((minval>0) + (minval<MAX) + (index == 1)) != 3)
{
stop = 0; /* initializing for clean start */
index = 1;
start = 1;
cls(2);
printf("This is a Small-C program\n");
printf("of a benchmark test by DH Parker\n");
printf("see CATS Newsletter of January 1990\n");
printf("\nStop calculation at what value less than %d ?\n",MAX);
gets(string); /* when to stop ? */
j = strlen(string);
strncpy(c,string,1);
start = atoi(c); /* makes string into integer */
for(i=0 ; i<j; i++) /* checks for correct input */
{
c = string[i];
stop = isdigit(string[i]); /* is it a digit ? */
index = stop * index;
}
minval = atoi(string);
if( j>5 ) /* are there too many digits ? */
{
index = 0;
}
if((j == 5) && (index == 1) && (start>3) )
{
index = 0;
}
if((minval>=MAX) || (minval<1) || (index == 0))
{
printf("\n\nI N V A L I D ! !"); /* error trapping */
printf("\n\nany key to try again\n q to quit");
c = getchar();
switch (c)
{
case 'q' : xcit(); /* 'fancy' exit */
}
}
}
cls(stdout); /* clear screen */
printf("Ready to find primes from 32767 to %d\n",minval);
printf("any key to begin\n"); /* inform and wait for */
getchar(); /* trigger */
{
/* start clock */
*d1 = date(); /* starting time */
for(index = MAX; index >= minval ; index -= 2)
{
while ((pos*100)> index) /* make newline to */
{ /* group by 100's */
--pos;
printf("\n");
}
while( index < tfsq ) /* reduce tfsq and */
{ /* testfactor when */
for( j = 0; j < 4 ; j++) /* possible */
{
tfsq -= testfactor;
tfsq++;
}
testfactor -= 2;
}
if(testfactor == 1 && index != 1 )
{ /* small primes */
printf("%6d",index);
}
for( j=3; ( j <= testfactor ); j += 2 )
{
if((index % j)==0) /* not prime */
break;
if(j >= testfactor) /* is prime */
printf("%6d",index);
}
}
if(minval < 3) /* to catch 2, */
{ /* the even prime */
printf("%6d",2);
}
}
*d2 = date(); /* checks time of finish */
secs = d2[1] -d1[1]; /* simple difference */
printf("\nRuntime = %d seconds in Small-C\n",secs);
printf("\nany key to exit");
getchar();
xcit();
}
xcit() /* a fancy (?) way to exit */
{ /* a function is like a defined procedure */
mode(8);
cls(2);
at(stdout,1,8);
ink(stdout,1);
printf("It's been good to");
csize(stdout,3,1);
at(stdout,3,11);
ink(stdout,2);
flash(stdout,1);
printf("'C'");
flash(stdout,0);
csize(stdout,0,0);
at(stdout,12,15);
ink(stdout,4);
printf("you");
at (stdout,17,5);
flash(stdout,1);
ink(stdout,6);
printf("any key to exit . . ._");
getchar();
mode(4);
flash(stdout,0);
exit(2);
}
/* The end of the small-c source code for dpbench7_c May 13, 1990 11am */
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.