tsc2597@acf4.UUCP (Sam Chin) (05/28/85)
<>
Here are benchmarks of four C compilers for MS-DOS. They are:
(1) Microsoft C Version 3.00
(2) Computer Innovations C86 V2.20J
(3) Aztec C V 2.20d
(4) Lattice C V2.14
All these compilers are fairly recent releases (within 6 months)
The benchmarks came from the August 1983 Byte magazine pages 88-92. They were
modified slightly to accomodate register variables. The machine they were run
on was a S-100 machine running MS-DOS 2.11. It had the following
configuration:
8086 CPU board from Lomas running at 8 Mhz
128K of no wait state CMOS static ram rated at 100ns
512K of RAM Drive
The benchmarks were run on the ram drive so the time taken to load was
negligible. The CPU board could have been run at 10 Mhz but was slowed down
to 8 Mhz for possible benchmarks against the Mac which has a 68000 running
at 8 Mhz. The benchmarks were done on both the large and small memory
models except for Aztec which only has the small model (The current release
supposedly supports the large model). A hand held stop watch was used and
the benchmarks were run twice for each one. The default switches were used
and no effort was made to set the switches for the maximum optimization
possible. The Microsoft C benchmarks execution times reflect the program
before the EXEMOD utility was used to compress the executable file. The
benchmarks are a floating point benchmark, the sieve benchmark, a quicksort
benchmark and a fibonacci number benchmark. The benchmark sources are given
at the end of this review for whosoever would like to try them on his/her
machine with his/her favourite compiler. All benchmark times are in seconds
and all file sizes are in bytes. Although I tried to be as careful as I
could there could be errors in my timings. I am not affiliated with any of
the companies that produce these compilers. I intend to test out two more
compilers soon - an Alpha test version of the Metaware C Compiler and the
Mark Williams C compiler.
Sam Chin
tsc2597.acf4@nyu.ARPA
allegra!cmcl2!acf4!tsc2597
MSC CIC86 AZTEC Lattice
Lg Sm Lg Sm Sm Lg Sm
float.c 154.7 153.9 488.3 396.3 192.95 128.0 131.83
size 22476 18996 13156 9781 6528 19128 15008
EXEPACKed (MSC) 20474 18304
sieve.c 3.83 2.91 7.59 5.81 3.17 5.10 5.05
size 16408 5844 12202 9467 4400 22044 20020
EXEPACKed (MSC) 7362 5850
sort.c 103.73 46.31 89.41 71.84 49.61 224.62 111.39
size 13580 10594 16807 13976 8864 19274 16386
EXEPACKed (MSC) 8182 6618
fibo.c 42.72 32.66 26.18 19.46 26.66 28.28 26.13
size 8256 5886 12195 9476 4432 13894 11870
EXEPACKed (MSC) 7404 5882
/* float.c */
#define CONST1 3.141597E0
#define CONST2 1.7839032E4
#define COUNT 10000
main()
{
double a, b, c;
register i;
a = CONST1;
b = CONST2;
for (i = 0; i < COUNT; ++i)
{
c = a * b;
c = c / a;
c = a * b;
c = c / a;
c = a * b;
c = c / a;
c = a * b;
c = c / a;
c = a * b;
c = c / a;
c = a * b;
c = c / a;
c = a * b;
c = c / a;
}
printf ("Done\n");
}
/* sieve.c */
#define true 1
#define false 0
#define size 8190
char flags[size+1];
main()
{ register i,k;
int prime,iter,count;
for (iter = 1; iter <= 10; iter++)
{
count = 0;
for (i = 0; i <= size; i++)
flags[i] = true;
for (i = 0; i <= size; i++)
{
if (flags[i])
{
prime = i + i + 3;
for (k=i+prime; k<=size; k+= prime)
flags[k] = false;
count++;
}
}
}
printf("\n%d primes.",count);
}
/* sort.c */
#include "stdio.h"
#define MAXNUM 1000
#define COUNT 10
#define MODULUS ((long) 0x20000)
#define C 13849L
#define A 25173L
long seed = 7L;
long random();
long buffer [MAXNUM] = {0};
main()
{
register i,j;
long temp;
printf("Filling array and sorting %d times\n", COUNT);
for (i = 0; i < COUNT; ++i)
{
for (j = 0; j < MAXNUM; ++j)
{
temp = random(MODULUS);
if (temp < 0L)
temp = (-temp);
buffer[j] = temp;
}
printf("Buffer full, iteration %d\n", i);
quick(0, MAXNUM, buffer);
}
printf("Done\n");
}
quick(lo, hi, base)
int lo, hi;
long base[];
{
register i,j;
long pivot, temp;
if (lo < hi)
{
for (i = lo, j = hi, pivot = base[hi]; i<j; )
{
while (i<j && base[i] < pivot)
++i;
while (j>i && base[j] > pivot)
--j;
if (i<j)
{
temp = base[i];
base[i] = base[j];
base[j] = temp;
}
}
temp = base[i];
base[i] = base[hi];
base[hi] = temp;
quick (lo, i-1, base);
quick (i+1, hi, base);
}
}
long random(size)
long size;
{
seed = seed * A + C;
return (seed % size);
}
/* fibo.c */
#include "stdio.h"
#define NTIMES 10
#define NUMBER 24
main()
{
register i;
unsigned value, fib();
printf("%d iterations: ", NTIMES);
for (i = 1; i <= NTIMES; i++)
value = fib(NUMBER);
printf("fibonacci(%d) = %u.\n",NUMBER, value);
exit(0);
}
unsigned fib(x)
int x;
{
if (x > 2)
return(fib(x-1) + fib(x-2));
else
return(1);
}Bicer.OsbuSouth@xerox.ARPA (05/29/85)
Sam, If you have the compile/assemble/link times, could you post them too? Thanks Jack Bicer BICER.ES@XEROX.ARPA