U From:	CSBVAX::MRGATE!mcvax!corto.inria.fr!shapiro@uunet.uu.net@SMTP 27-APR-1988 12:18  To:	ARISIA::EVERHART( Subj:	D(h)rystone benchmarks on C++, G++    K Received: from uunet.UU.NET by prep.ai.mit.edu; Wed, 27 Apr 88 10:33:10 EST @ Received: from mcvax.UUCP by uunet.UU.NET (5.54/1.14) with UUCP ( 	id AA05092; Wed, 27 Apr 88 11:51:29 EDT> Received: by mcvax.cwi.nl; Wed, 27 Apr 88 16:19:27 +0200 (MET)i Received: from blueberry.inria.fr (blueberry.uucp) by inria.inria.fr; Tue, 26 Apr 88 18:30:04 +0200 (MET) 6 Received: by blueberry.inria.fr (3.2/client.23-dec-86)* 	id AA28425; Tue, 26 Apr 88 18:29:27 +0200# Date: Tue, 26 Apr 88 18:29:27 +0200 3 Message-Id: <8804261629.AA28425@blueberry.inria.fr> ; Organization: INRIA, BP 105, 78153 Le Chesnay Cedex, France H 	telephone +33(1)39-63-55-11, telex 697033 F, telecopy +33(1)39-63-53-30B From: Philippe Gautron <mcvax!corto.inria.fr!gautron@uunet.uu.net>1 Sender: mcvax!corto.inria.fr!shapiro@uunet.uu.net  To: info-g++@prep.ai.mit.edu+ Subject: D(h)rystone benchmarks on C++, G++   E     Drystone is a benchmark program which measures processor+compiler E     efficiency in executing a 'typical' program. My purpose is NOT to E     know if this program is good, good enough, bad for these measures >     but to compare them on a same site (and same conditions) :     - pcc as reference,      - gcc, the GNU C compiler ?     - C++ (ATT version 1.1), cfront translator and pcc: C++.pcc ?     - C++ (ATT version 1.1), cfront translator and gcc: C++.gcc 9                       [cfront compiled by C++.gcc itself] .     - G++, the GNU C++ compiler (version 1.18)  & Machine: SUN 3/260, STANDALONE, 8M RAM@ All compilations with -O.  All compiles include the standard Sun libraries, not gnulib.2 Two tests: with and without register declarations.    dry.c: (version C/1.1, 12/01/84)<  *	Date:		PROGRAM updated 01/06/86, RESULTS updated 03/31/861  *	Compile:	cc -O dry.c -o drynr			: No registers 3  *			cc -O -DREG=register dry.c -o dryr	: Registers   ) 1) First, a bug in dry.c: procedure Proc3 
 struct	Record  {  	struct Record		*PtrComp;          ...  };  " typedef struct Record 	RecordType; typedef RecordType *	RecordPtr;      Proc1(PtrParIn)  REG RecordPtr	PtrParIn;  { ) #define	NextRecord	(*(PtrParIn->PtrComp))          ... 8 	Proc3(NextRecord.PtrComp);	<== call with struct Record* 	... }      Proc3(PtrParOut)6 RecordPtr	*PtrParOut;		<== called with struct Record**  L This bug does not abort the execution. I have translate dry.c in C++ syntax,: and the first compilation aborts on the Proc3 declaration.    ! 2) Second, the results (average):  Uptime=   9:36am  up 2 mins,  0 user,  load average: 0.08, 0.00, 0.00      - pcc, drynr* Dhrystone(1.1) time for 500000 passes = 841 This machine benchmarks at 5919 dhrystones/second    - pcc, dryr * Dhrystone(1.1) time for 500000 passes = 781 This machine benchmarks at 6378 dhrystones/second    - gcc, drynr* Dhrystone(1.1) time for 500000 passes = 731 This machine benchmarks at 6815 dhrystones/second    - gcc, dryr * Dhrystone(1.1) time for 500000 passes = 731 This machine benchmarks at 6811 dhrystones/second    - C++ 1.1 with pcc, drynr 7 Dhrystone(1.1 (C++ syntax)) time for 500000 passes = 85 1 This machine benchmarks at 5850 dhrystones/second    - C++ 1.1 with pcc, drynr 7 Dhrystone(1.1 (C++ syntax)) time for 500000 passes = 86 1 This machine benchmarks at 5759 dhrystones/second    - C++ 1.1 with gcc, drynr 7 Dhrystone(1.1 (C++ syntax)) time for 500000 passes = 73 1 This machine benchmarks at 6761 dhrystones/second    - C++ 1.1 with gcc, dryr7 Dhrystone(1.1 (C++ syntax)) time for 500000 passes = 73 1 This machine benchmarks at 6765 dhrystones/second    - G++ 1.18, drynr 7 Dhrystone(1.1 (C++ syntax)) time for 500000 passes = 71 1 This machine benchmarks at 7038 dhrystones/second    - G++ 1.18, dryr7 Dhrystone(1.1 (C++ syntax)) time for 500000 passes = 71 1 This machine benchmarks at 7040 dhrystones/second    3) Conclusion:  ?    register declaration are interesting with pcc, less with gcc     but pcc is good for loops.   &    G++ > gcc > C++.gcc > pcc > C++.pcc  ;    There is a interesting gap between C++.pcc and C++.gcc.     If you have some comments..   
 P. Gautron   ------ Here is my C++ source  ------  8 /*	EVERBODY:	Please read "APOLOGY" below. -rick 01/06/85  *   *	"DHRYSTONE" Benchmark Program  *  *	Version:	C/1.1, 12/01/84   *<  *	Date:		PROGRAM updated 01/06/86, RESULTS updated 03/31/86  *D  *	Author:		Reinhold P. Weicker,  CACM Vol 27, No 10, 10/84 pg. 1013+  *			Translated from ADA by Rick Richardson 9  *			Every method to preserve ADA-likeness has been used,   *			at the expense of C-ness.  *1  *	Compile:	cc -O dry.c -o drynr			: No registers 3  *			cc -O -DREG=register dry.c -o dryr	: Registers   *5  *	Defines:	Defines are provided for old C compiler's 9  *			which don't have enums, and can't assign structures. 4  *			The time(2) function is library dependant; Most9  *			return the time in seconds, but beware of some, like '  *			Aztec C, which return other units. 7  *			The LOOPS define is initially set for 50000 loops. 5  *			If you have a machine with large integers and is 6  *			very fast, please change this number to 500000 to3  *			get better accuracy.  Please select the way to 6  *			measure the execution time using the TIME define.7  *			For single user machines, time(2) is adequate. For 9  *			multi-user machines where you cannot get single-user 4  *			access, use the times(2) function.  If you have3  *			neither, use a stopwatch in the dead of night. 5  *			Use a "printf" at the point marked "start timer" 9  *			to begin your timings. DO NOT use the UNIX "time(1)" 4  *			command, as this will measure the total time to7  *			run this program, which will (erroneously) include 5  *			the time to malloc(3) storage and to compute the !  *			time it takes to do nothing.   *  *	Run:		drynr; dryr  *B  *	Results:	If you get any new machine/OS results, please send to:  *  *				ihnp4!castor!pcrat!rick   *  *			and thanks to all that do.   *;  *	Note:		I order the list in increasing performance of the 9  *			"with registers" benchmark.  If the compiler doesn't 3  *			provide register variables, then the benchmark (  *			is the same for both REG and NOREG.  *=  *	PLEASE:		Send complete information about the machine type, 4  *			clock speed, OS and C manufacturer/version.  If4  *			the machine is modified, tell me what was done.:  *			On UNIX, execute uname -a and cc -V to get this info.  *A  *	80x8x NOTE:	80x8x benchers: please try to do all memory models   *			for a particular compiler.   *  *	APOLOGY (1/30/86): >  *		Well, I goofed things up!  As pointed out by Haakon Bugge,=  *		the line of code marked "GOOF" below was missing from the ;  *		Dhrystone distribution for the last several months.  It =  *		*WAS* in a backup copy I made last winter, so no doubt it 2  *		was victimized by sleepy fingers operating vi!  *B  *		The effect of the line missing is that the reported benchmarks>  *		are 15% too fast (at least on a 80286).  Now, this creates;  *		a dilema - do I throw out ALL the data so far collected :  *		and use only results from this (corrected) version, or7  *		do I just keep collecting data for the old version?   *<  *		Since the data collected so far *is* valid as long as it6  *		is compared with like data, I have decided to keep9  *		TWO lists- one for the old benchmark, and one for the :  *		new.  This also gives me an opportunity to correct one>  *		other error I made in the instructions for this benchmark.7  *		My experience with C compilers has been mostly with >  *		UNIX 'pcc' derived compilers, where the 'optimizer' simply9  *		fixes sloppy code generation (peephole optimization). C  *		But today, there exist C compiler optimizers that will actually C  *		perform optimization in the Computer Science sense of the word, =  *		by removing, for example, assignments to a variable whose <  *		value is never used.  Dhrystone, unfortunately, provides8  *		lots of opportunities for this sort of optimization.  *:  *		I request that benchmarkers re-run this new, corrected=  *		version of Dhrystone, turning off or bypassing optimizersi:  *		which perform more than peephole optimization.  Please=  *		indicate the version of Dhrystone used when reporting thee  *		results to me.  *		  *H  *	The following program contains statements of a high-level programming<  *	language (C) in a distribution considered representative:  *  *	assignments			53%  *	control statements		32%   *	procedure, function calls	15%  *I  *	100 statements are dynamically executed.  The program is balanced with1   *	respect to the three aspects:  *		- statement type*  *		- operand type (for simple data types)  *		- operand access3  *			operand global, local, parameter, or constant.0  *I  *	The combination of these three aspects is balanced only approximately.s  *?  *	The program does not compute anything meaningfull, but it ise*  *	syntactically and semantically correct.  *  */!  H /* Accuracy of timings and human fatigue controlled by next two lines */B //const LOOPS =	50000;		/* Use this for slow or 16 bit machines */9 const LOOPS =	500000;		/* Use this for faster machines */     /* Compiler dependent options */6 #undef	NOENUM			/* Define if compiler has no enum's */G #undef	NOSTRUCTASSIGN		/* Define if compiler can't assign structures */e  - /* define only one of the next two defines */i0 #define TIMES			/* Use times(2) time function */0 /*#define TIME			/* Use time(2) time function */  B /* define the granularity of your times(2) function (when used) */9 const HZ =	60;		/* times(2) returns 1/60 second (most) */ = //const HZ =	100;		/* times(2) returns 1/100 second (WECo) */G  . /* for compatibility with goofed up version */> /*#undef GOOF			/* Define if you want the goofed up version */   #ifdef GOOFn char	Version[] = "1.0";g #else $ char	Version[] = "1.1 (C++ syntax)"; #endif   #ifdef	NOSTRUCTASSIGN/8 #define	structassign(d, s)	memcpy(&(d), &(s), sizeof(d)) #elsee  #define	structassign(d, s)	d = s #endif  
 #ifdef	NOENUMr const	Ident1 =	1;G const	Ident2 =	2;d const	Ident3 =	3;  const	Ident4 =	4;d const	Ident5 =	5;c #elseu: enum Enumeration {Ident1, Ident2, Ident3, Ident4, Ident5}; #endif   typedef int	OneToThirty; typedef int	OneToFifty;R typedef char	CapitalLetter;n typedef char	String30[31]; typedef int	Array1Dim[51]; typedef int	Array2Dim[51][51];  
 struct	Recordc {. 	Record			*PtrComp;t 	Enumeration		Discr; 	Enumeration		EnumComp;) 	OneToFifty		IntComp;	 	String30		StringComp; };   typedef int		boolean;    const	NULL =		0; const	TRUE =		1; const	FALSE =		0;,   #ifndef REG  #define	REGb #endif  8 extern Enumeration	Func1( CapitalLetter, CapitalLetter);, extern boolean		Func2( String30, String30 );   // C++ declararions0% extern boolean		Func3( Enumeration );t= extern void		Proc0(), Proc1( Record* ), Proc2( OneToFifty* ),y' 			Proc3( Record** ), Proc4(), Proc5(),(& 			Proc6( Enumeration, Enumeration* ),0 			Proc7( OneToFifty, OneToFifty, OneToFifty* ),9 			Proc8( Array1Dim, Array2Dim, OneToFifty, OneToFifty );s extern int		exit( int ), 			printf( const char*, ... );1 extern char*		strcpy( const char*, const char* ),h& 			strcmp( const char*, const char* );   #ifdef TIMES #include <sys/types.h> #include <sys/times.h> #endif   main() {a	 	Proc0(); 	 	exit(0);e }n   /*  * Package 1  */s
 int		IntGlob;+ boolean		BoolGlob; char		Char1Glob; char		Char2Glob; Array1Dim	Array1Glob;  Array2Dim	Array2Glob;k Record*	PtrGlb;n Record*	PtrGlbNext;.   void Proc0() {  	OneToFifty		IntLoc1;a 	REG OneToFifty		IntLoc2;= 	OneToFifty		IntLoc3;h 	REG char		CharLoc;n 	REG char		CharIndex;  	Enumeration	 	EnumLoc;( 	String30		String1Loc; 	String30		String2Loc; //	extern char		*malloc(); 	register unsigned int	i;    #ifdef TIME  	long			time( long* ); 	long			starttime; 	long			benchtime; 	long			nulltime;    	starttime = time(0);  	for (i = 0; i < LOOPS; ++i);(> 	nulltime = time(0) - starttime; /* Computes o'head of loop */ #endif #ifdef TIMES 	time_t			starttime; 	time_t			benchtime; 	time_t			nulltime;e 	struct tms		tms;e  ( 	times(&tms); starttime = tms.tms_utime; 	for (i = 0; i < LOOPS; ++i);c
 	times(&tms); I 	nulltime = tms.tms_utime - starttime; /* Computes overhead of looping */o #endif   	PtrGlbNext = new Record;- 	PtrGlb = new Record;  	PtrGlb->PtrComp = PtrGlbNext; 	PtrGlb->Discr = Ident1; 	PtrGlb->EnumComp = Ident3;" 	PtrGlb->IntComp = 40;> 	strcpy(PtrGlb->StringComp, "DHRYSTONE PROGRAM, SOME STRING"); #ifndef	GOOF? 	strcpy(String1Loc, "DHRYSTONE PROGRAM, 1'ST STRING");	/*GOOF*/2 #endif> 	Array2Glob[8][7] = 10;	/* Was missing in published program */   /***************** -- Start Timer --s *****************/ #ifdef TIMEe 	starttime = time(0);C #endif #ifdef TIMES( 	times(&tms); starttime = tms.tms_utime; #endif 	for (i = 0; i < LOOPS; ++i) 	{  
 		Proc5();
 		Proc4(); 		IntLoc1 = 2; 		IntLoc2 = 3;7 		strcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING");  		EnumLoc = Ident2;t- 		BoolGlob = ! Func2(String1Loc, String2Loc);  		while (IntLoc1 < IntLoc2)f 		{,# 			IntLoc3 = 5 * IntLoc1 - IntLoc2;h% 			Proc7(IntLoc1, IntLoc2, &IntLoc3);i
 			++IntLoc1;5 		}l2 		Proc8(Array1Glob, Array2Glob, IntLoc1, IntLoc3); 		Proc1(PtrGlb);< 		for (CharIndex = 'A'; CharIndex <= Char2Glob; ++CharIndex)( 			if (EnumLoc == Func1(CharIndex, 'C')) 				Proc6(Ident1, &EnumLoc); 		IntLoc3 = IntLoc2 * IntLoc1; 		IntLoc2 = IntLoc3 / IntLoc1;. 		IntLoc2 = 7 * (IntLoc3 - IntLoc2) - IntLoc1; 		Proc2(&IntLoc1); 	}   /***************** -- Stop Timer -- *****************/   #ifdef TIME , 	benchtime = time(0) - starttime - nulltime;4 	printf("Dhrystone(%s) time for %ld passes = %ld\n",
 		Version, 		(long) LOOPS, benchtime);I= 	printf("This machine benchmarks at %ld dhrystones/second\n",  		((long) LOOPS) / benchtime); #endif #ifdef TIMES
 	times(&tms);e2 	benchtime = tms.tms_utime - starttime - nulltime;4 	printf("Dhrystone(%s) time for %ld passes = %ld\n",
 		Version, 		(long) LOOPS, benchtime/HZ);= 	printf("This machine benchmarks at %ld dhrystones/second\n",c# 		((long) LOOPS) * HZ / benchtime);o #endif   }t  ! void Proc1 (REG Record* PtrParIn)r {m) #define	NextRecord	(*(PtrParIn->PtrComp))r  # 	structassign(NextRecord, *PtrGlb);i 	PtrParIn->IntComp = 5;e( 	NextRecord.IntComp = PtrParIn->IntComp;( 	NextRecord.PtrComp = PtrParIn->PtrComp;% 	Proc3((Record**)NextRecord.PtrComp);e  	if (NextRecord.Discr == Ident1) 	{ 		NextRecord.IntComp = 6;e2 		Proc6(PtrParIn->EnumComp, &NextRecord.EnumComp);' 		NextRecord.PtrComp = PtrGlb->PtrComp; 5 		Proc7(NextRecord.IntComp, 10, &NextRecord.IntComp);r 	} 	else & 		structassign(*PtrParIn, NextRecord);   #undef	NextRecordO }(  ! void Proc2 (OneToFifty* IntParIO)  {  	REG OneToFifty		IntLoc; 	REG Enumeration		EnumLoc;   	IntLoc = *IntParIO + 10;i 	for(;;) 	{ 		if (Char1Glob == 'A')n 		{t 			--IntLoc;  			*IntParIO = IntLoc - IntGlob; 			EnumLoc = Ident1; 		}, 		if (EnumLoc == Ident1)	 			break;b 	} }y   void Proc3 (Record** PtrParOut)  {e 	if (PtrGlb != 0)i 		*PtrParOut = PtrGlb->PtrComp;s 	elser 		IntGlob = 100;& 	Proc7(10, IntGlob, &PtrGlb->IntComp); }	   void Proc4() {o 	REG boolean	BoolLoc;a   	BoolLoc = Char1Glob == 'A'; 	BoolLoc |= BoolGlob;c 	Char2Glob = 'B';* }o   void Proc5() {t 	Char1Glob = 'A';d 	BoolGlob = FALSE; }c   // extern boolean Func3();  D void Proc6( REG Enumeration	EnumParIn, REG Enumeration* EnumParOut ) {e 	*EnumParOut = EnumParIn;t 	if (! Func3(EnumParIn) )o 		*EnumParOut = Ident4;s 	switch (EnumParIn)n 	{* 	case Ident1:	*EnumParOut = Ident1; break;6 	case Ident2:	if (IntGlob > 100) *EnumParOut = Ident1; 			else *EnumParOut = Ident4;w	 			break;N* 	case Ident3:	*EnumParOut = Ident2; break; 	case Ident4:	break;# 	case Ident5:	*EnumParOut = Ident3;t 	} }o  M void Proc7 (OneToFifty IntParI1, OneToFifty IntParI2, OneToFifty* IntParOut )e {r 	REG OneToFifty	IntLoc;p   	IntLoc = IntParI1 + 2;o  	*IntParOut = IntParI2 + IntLoc; }s  5 void Proc8 (Array1Dim Array1Par, Array2Dim Array2Par, L                                    OneToFifty IntParI1, OneToFifty IntParI2) {t 	REG OneToFifty	IntLoc;u 	REG OneToFifty	IntIndex;n   	IntLoc = IntParI1 + 5;e 	Array1Par[IntLoc] = IntParI2;) 	Array1Par[IntLoc+1] = Array1Par[IntLoc];  	Array1Par[IntLoc+30] = IntLoc; < 	for (IntIndex = IntLoc; IntIndex <= (IntLoc+1); ++IntIndex)' 		Array2Par[IntLoc][IntIndex] = IntLoc;* 	++Array2Par[IntLoc][IntLoc-1];t2 	Array2Par[IntLoc+20][IntLoc] = Array1Par[IntLoc];
 	IntGlob = 5;t }   B Enumeration Func1 (CapitalLetter CharPar1, CapitalLetter CharPar2) {t 	REG CapitalLetter	CharLoc1; 	REG CapitalLetter	CharLoc2;   	CharLoc1 = CharPar1;t 	CharLoc2 = CharLoc1;a 	if (CharLoc2 != CharPar2) 		return (Ident1); 	elset 		return (Ident2); }n  4 boolean Func2 (String30	StrParI1, String30 StrParI2) {o 	REG OneToThirty		IntLoc;e 	REG CapitalLetter	CharLoc;e   	IntLoc = 1; 	while (IntLoc <= 1)< 		if (Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) == Ident1) 		{  			CharLoc = 'A';l 			++IntLoc; 		}n& 	if (CharLoc >= 'W' && CharLoc <= 'Z')
 		IntLoc = 7;c 	if (CharLoc == 'X') 		return(TRUE);r 	elsey 	{% 		if (strcmp(StrParI1, StrParI2) > 0)	 		{e 			IntLoc += 7;  			return (TRUE);  		}  		else 			return (FALSE); 	} }s  * boolean Func3( REG Enumeration EnumParIn ) {  	REG Enumeration	EnumLoc;n   	EnumLoc = EnumParIn;'& 	if (EnumLoc == Ident3) return (TRUE); 	return (FALSE); }g   #ifdef	NOSTRUCTASSIGNf memcpy(d, s, l)h register char	*d;* register char	*s;	 register int	l;i {f 	while (l--) *d++ = *s++;	 }  #endif  