Need 286 "C" benchmark

Dave Trissel davet at oakhill.UUCP
Sat May 18 03:09:27 AEST 1985


Computer Architecture Fans:

Could you help us in an experiment?  We need to run the following benchmark
on 286 and 68k machines.  If you have the Intel 310 sytem or the IBM PC/AT
(or any other 286 system) we would greatly appreciate the results.

The benchmark comes from a description in Doug Hoffsteder's "Godel, Escher,
Bach".

[Thanks to Charles River Data Systems for providing the "C" source.]

Dave Trissel           {ihnp4,seismo,gatech,ctvax}!ut-sally!oakhill!davet
Motorola Semiconductor Inc.  Austin, Texas
-----------------------------------------------------------------------

	Below is a source listing of a C program.  The program takes each
integer from 1 to 999 and checks to see if it is even or positive.  If the
number is even it divides it by 2, if it is odd the number is multiplied by
3 and then 1 is added.  Then back to the even-odd test with the mentioned
changes until the number is one.  After that the next number in the 1 to 999
range is manipulated and so one.  After this is completed the next part of
the program does the same thing, except this time it keeps a histogram of all
the values of the number.


#include <stdio.h>
main()
{
	register int i, k, j;
	register unsigned int max = 0;
	for (i=1; i < 1000; ++i) {
		k= i;
		while (k != 1) {
			if (max < k) max = k;
			j = k/2;
			j = j*2;
			if (j == k)
				k = k/2;
			else	k = k*3 + 1;
		}
	}
	hst(max);
}
hst(max)
	register unsigned int max;
{
	register int i, k, j;
	short *h = calloc(max+1,sizeof(short));
	for (i=1; i < 1000; ++i) {
		k= i;
		while (k != 1) {
			++(h[k]);
			j = k/2;
			j = j*2;
			if (j == k)
				k = k/2;
			  else    k = k*3+1;
		}
	}
}
-----------------------------------------------------------------------



More information about the Comp.lang.c mailing list