.24SEP93 DHRY C S71DHRY COMU:،DHRY280 COM8V`DRHY FOR /* EVERBODY: Please read "APOLOGY" below. -rick 01/06/85 * See introduction in net.arch, or net.micro * * "DHRYSTONE" Benchmark Program * * Version: C/1.1, 12/01/84 * * Date: PROGRAM updated 01/06/86, RESULTS updated 03/31/86 * * Author: Reinhold P. Weicker, CACM Vol 27, No 10, 10/84 pg. 1013 * Translated from ADA by Rick Richardson * Every method to preserve ADA-likeness has been used, * at the expense of C-ness. * * Compile: cc -O dry.c -o drynr : No registers * cc -O -DREG=register dry.c -o dryr : Registers * * Defines: Defines are provided for old C compiler's * which don't have enums, and can't assign structures. * The time(2) function is library dependant; Most * return the time in seconds, but beware of some, like * Aztec C, which return other units. * The LOOPS define is initially set for 50000 loops. * If you have a machine with large integers and is * very fast, please change this number to 500000 to * get better accuracy. Please select the way to * measure the execution time using the TIME define. * For single user machines, time(2) is adequate. For * multi-user machines where you cannot get single-user * access, use the times(2) function. If you have * neither, use a stopwatch in the dead of night. * Use a "printf" at the point marked "start timer" * to begin your timings. DO NOT use the UNIX "time(1)" * command, as this will measure the total time to * run this program, which will (erroneously) include * the time to malloc(3) storage and to compute the * time it takes to do nothing. * * 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% * * 100 statements are dynamically executed. The program is balanced with * respect to the three aspects: * - statement type * - operand type (for simple data types) * - operand access * operand global, local, parameter, or constant. * * The combination of these three aspects is balanced only approximately. * * The program does not compute anything meaningfull, but it is * syntactically and semantically correct. * */ #include /* Accuracy of timings and human fatigue controlled by next two lines */ #define LOOPS 65500 /* Use this for slow or 16 bit machines */ /* #define LOOPS 500000 */ /* Use this for faster machines */ /* Compiler dependent options */ /* #define NOENUM */ /* Define if compiler has no enum's */ /* #define NOSTRUCTASSIGN */ /* Define if compiler can't assign structures */ /* define only one of the next two defines */ /* #define TIMES */ /* Use times(2) time function */ #define TIME /* Use time(2) time function */ /* define the granularity of your times(2) function (when used) */ /* #define HZ 60 */ /* times(2) returns 1/60 second (most) */ /* #define HZ 100 */ /* times(2) returns 1/100 second (WECo) */ /* for compatibility with goofed up version */ /*#define GOOF */ /* Define if you want the goofed up version */ #ifdef GOOF char Version[] = "1.0"; #else char Version[] = "1.1"; #endif #ifdef NOSTRUCTASSIGN #define structassign(d, s) bcopy(&(s), &(d), sizeof(d)) #else #define structassign(d, s) d = s #endif #ifdef NOENUM #define Ident1 1 #define Ident2 2 #define Ident3 3 #define Ident4 4 #define Ident5 5 typedef int Enumeration; #else typedef enum {Ident1, Ident2, Ident3, Ident4, Ident5} Enumeration; #endif typedef int OneToThirty; typedef int OneToFifty; typedef char CapitalLetter; typedef char String30[31]; typedef int Array1Dim[51]; typedef int Array2Dim[51][51]; struct Record { struct Record *PtrComp; Enumeration Discr; Enumeration EnumComp; OneToFifty IntComp; String30 StringComp; }; typedef struct Record RecordType; typedef RecordType * RecordPtr; typedef int boolean; #define TRUE 1 #define FALSE 0 #ifndef REG #define REG register #endif extern Enumeration Func1(); extern boolean Func2(); #ifdef TIMES #include #include #endif main() { Proc0(); exit(0); } /* * Package 1 */ int IntGlob; boolean BoolGlob; char Char1Glob; char Char2Glob; Array1Dim Array1Glob; Array2Dim Array2Glob; RecordPtr PtrGlb; RecordPtr PGlbNext; Proc0() { OneToFifty IntLoc1; REG OneToFifty IntLoc2; OneToFifty IntLoc3; REG char CharLoc; REG char CharIndex; Enumeration EnumLoc; String30 String1Loc; String30 String2Loc; extern char *malloc(); unsigned int i; #ifdef TIME long time(); long starttime; long benchtime; long nulltime; starttime = time( (long *) 0); for (i = 0; i < LOOPS; ++i); nulltime = time( (long *) 0) - starttime; /* Computes o'head of loop */ #endif #ifdef TIMES time_t starttime; time_t benchtime; time_t nulltime; struct tms tms; unsigned int i; times(&tms); starttime = tms.tms_utime; for (i = 0; i < LOOPS; ++i); times(&tms); nulltime = tms.tms_utime - starttime; /* Computes overhead of looping */ #endif PGlbNext = (RecordPtr) malloc(sizeof(RecordType)); PtrGlb = (RecordPtr) malloc(sizeof(RecordType)); PtrGlb->PtrComp = PGlbNext; 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*/ #endif Array2Glob[8][7] = 10; /* Was missing in published program */ /***************** -- Start Timer -- *****************/ #ifdef TIME starttime = time( (long *) 0); #endif #ifdef TIMES times(&tms); starttime = tms.tms_utime; #endif for (i = 0; i < LOOPS; ++i) { Proc5(); Proc4(); IntLoc1 = 2; IntLoc2 = 3; strcpy(String2Loc, "DHRYSTONE PROGRAM, 2'ND STRING"); EnumLoc = Ident2; BoolGlob = ! Func2(String1Loc, String2Loc); while (IntLoc1 < IntLoc2) { IntLoc3 = 5 * IntLoc1 - IntLoc2; Proc7(IntLoc1, IntLoc2, &IntLoc3); ++IntLoc1; } 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( (long *) 0) - starttime - nulltime; printf("Dhrystone(%s) time for %ld passes = %ld\n", Version, (long) LOOPS, benchtime); printf("This machine benchmarks at %ld dhrystones/second\n", ((long) LOOPS) / benchtime); #endif #ifdef TIMES times(&tms); benchtime = tms.tms_utime - starttime - nulltime; printf("Dhrystone(%s) time for %ld passes = %ld\n", Version, (long) LOOPS, benchtime/HZ); printf("This machine benchmarks at %ld dhrystones/second\n", ((long) LOOPS) * HZ / benchtime); #endif } Proc1(PtrParIn) REG RecordPtr PtrParIn; { #define NextRecord (*(PtrParIn->PtrComp)) structassign(NextRecord, *PtrGlb); PtrParIn->IntComp = 5; NextRecord.IntComp = PtrParIn->IntComp; NextRecord.PtrComp = PtrParIn->PtrComp; Proc3(NextRecord.PtrComp); if (NextRecord.Discr == Ident1) { NextRecord.IntComp = 6; Proc6(PtrParIn->EnumComp, &NextRecord.EnumComp); NextRecord.PtrComp = PtrGlb->PtrComp; Proc7(NextRecord.IntComp, 10, &NextRecord.IntComp); } else structassign(*PtrParIn, NextRecord); #undef NextRecord } Proc2(IntParIO) OneToFifty *IntParIO; { REG OneToFifty IntLoc; REG Enumeration EnumLoc; IntLoc = *IntParIO + 10; for(;;) { if (Char1Glob == 'A') { --IntLoc; *IntParIO = IntLoc - IntGlob; EnumLoc = Ident1; } if (EnumLoc == Ident1) break; } } Proc3(PtrParOut) RecordPtr *PtrParOut; { if (PtrGlb != NULL) *PtrParOut = PtrGlb->PtrComp; else IntGlob = 100; Proc7(10, IntGlob, &PtrGlb->IntComp); } Proc4() { REG boolean BoolLoc; BoolLoc = Char1Glob == 'A'; BoolLoc |= BoolGlob; Char2Glob = 'B'; } Proc5() { Char1Glob = 'A'; BoolGlob = FALSE; } extern boolean Func3(); Proc6(EnumParIn, EnumParOut) REG Enumeration EnumParIn; REG Enumeration *EnumParOut; { *EnumParOut = EnumParIn; if (! Func3(EnumParIn) ) *EnumParOut = Ident4; switch (EnumParIn) { case Ident1: *EnumParOut = Ident1; break; case Ident2: if (IntGlob > 100) *EnumParOut = Ident1; else *EnumParOut = Ident4; break; case Ident3: *EnumParOut = Ident2; break; case Ident4: break; case Ident5: *EnumParOut = Ident3; } } Proc7(IntParI1, IntParI2, IntParOut) OneToFifty IntParI1; OneToFifty IntParI2; OneToFifty *IntParOut; { REG OneToFifty IntLoc; IntLoc = IntParI1 + 2; *IntParOut = IntParI2 + IntLoc; } Proc8(Array1Par, Array2Par, IntParI1, IntParI2) Array1Dim Array1Par; Array2Dim Array2Par; OneToFifty IntParI1; OneToFifty IntParI2; { REG OneToFifty IntLoc; REG OneToFifty IntIndex; IntLoc = IntParI1 + 5; 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]; Array2Par[IntLoc+20][IntLoc] = Array1Par[IntLoc]; IntGlob = 5; } Enumeration Func1(CharPar1, CharPar2) CapitalLetter CharPar1; CapitalLetter CharPar2; { REG CapitalLetter CharLoc1; REG CapitalLetter CharLoc2; CharLoc1 = CharPar1; CharLoc2 = CharLoc1; if (CharLoc2 != CharPar2) return (Ident1); else return (Ident2); } boolean Func2(StrParI1, StrParI2) String30 StrParI1; String30 StrParI2; { REG OneToThirty IntLoc; REG CapitalLetter CharLoc; IntLoc = 1; while (IntLoc <= 1) if (Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) == Ident1) { CharLoc = 'A'; ++IntLoc; } if (CharLoc >= 'W' && CharLoc <= 'Z') IntLoc = 7; if (CharLoc == 'X') return(TRUE); else { if (strcmp(StrParI1, StrParI2) > 0) { IntLoc += 7; return (TRUE); } else return (FALSE); } } boolean Func3(EnumParIn) REG Enumeration EnumParIn; { REG Enumeration EnumLoc; EnumLoc = EnumParIn; if (EnumLoc == Ident3) return (TRUE); return (FALSE); } *!4RMD kb6!!N# 6!͂ *4=o I!o !srut66 nf#utnfͱ8^Vnf!srut!%")2!%",2[)2s#r*,2666(6![,2!ͦ!!ͦ! "!!srut66^16666!1!ͦ6!!+}!(+"Dnf^VRut!nfnfnf#ut^Vnfͱnnfnf!!12*,26A+!C~og }ݾ !!j4F:.2͝^Vnfut^VutnfR^VRut++ͳnf#utnfͱ"^Vnf^Vnf!srut!!!P ! 9^Vnf!!y nf*,2^V%66^Vnf####s#r^V+++++s#rkbN#Fnf##~ D##s#r++n&j*,2N#Fnfq#p###! nf####N#Fnf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GDHRYSTONE PROGRAM, 1'ST STRINGDHRYSTONE PROGRAM, 2'ND STRINGDhrystone(%s) time for %ld passes = %ld This machine benchmarks at %ld dhrystones/second (null)22      AAAAAABBBBBB 0123456789ABCDEF*!~3RMD kb6!!N# 6!͔ *i3=́ I!́ ͥ!.66 &#.&8&!.!%"0!%"0[0s#r*0666(6![0!p!*p! "!.66'ͨ6666!*p6**[}!(+"1&.*&&@&#.&L&&!!0_*0͗6A(!C~og9}ݾ *!4F:0ͬ&..&.++7&#.& &&!.!!!&! 9&!!D&Ý͑&*0%66&####s#r+++++s#rkbN#Fv&##~ @##s#r++n&*0N#F&q#p###! &####N#F@Ý&%Ý͑&N#F! .:0A &+.[0&s#r6~ Ý͑*0}( N#F&q#p!d"0*0####*0! @Ý͑:0A!(+.[}o|g.>B20Ý>A20!"͑&~wo& } 6~(!(('ʝ(%Ý[0!d+6Ý6Ý6Ý6Ý͑&##.&& s#rÝ͑ !.) s#r&)N#F&#)q#p!)s#rkb.&&)f&s#r&#.&#&+)f&N#Fp+q&)N#F&)!fq#p!"0Ý͑~w~w~ݾ(.Ý.Ý͑665&#~og&~og9} 6A&#.!jW~ͬ~_W!Z66~X !Ý&&V!&.!Ý͑~w~ !Ý!Ý͑!nf!͆Ý͑*e1~og8 Ý͑nf>}2b1#^!V Ýͥnf nf"e1) ~%( ogE) 6 6666~- #4~0!(+u^!V(Z:b1w~* n f ~##u t w#~. 0#~* n f ~##u t w#$Z:b1w~ !n&u~l #6~#wʝDO("X cʵ d(jo(s u( x(_ 6~( ~w6~_W!F(6!En&nnn~ n f ^#V#~#fo 66n f N#FCc1#u t i`} !v"c1*c1͂u~(Fͬ0~wF~ͬ0 ~ݖw6~ &! E~5 *c1~#"c1ogE~5 ~) ! E~5 ) n f ~##u t w+"c165 ~n f ^#V !zog4!9un&)n f u t ! EF5~ͬ8~#w ÝN(?~ y ! 8 &}(+.&q#.i`È ͑nf N ~ :66!!n& R n&Ý!Ý!nfn& R(66~nfw#ut 66n(͑6!}T ~w Ý͑nf~ !Ýͻ ~w~(^ nfe 66n&uR(n !Ý͑nfN(~(^V!Rut} !Ýnfnfn& ^VR(66nfutn(!Ý͑*g3}( nf"g3 !Ý͑nf*g3ut"g3Ý͑/ nfÝ× :~!U_^Vnf nu~!U_!5 ~ݶݶݶ ~ _W!!ѷR^u u^ nb0~ w! nfͤF 5 ~ ͬ3~('!-nfͤ5 ~#ognfͤ~ 5 n&Ý͎&&88M͝.͎|ͰYP)͎MYP͎͝|Ͱ)͎͝M͝!R!B|MD!BMD!B{>xRR8<)jz_RRҐ3333?:= x(x!8 ,!!yHyyx?0Z)jS|3*|3} !~3"|38  8r8!*|3"|3*|3 r!+ # !!++KB~# i`!#!9!9##91.1DHRYSTONE PROGRAM, SOME STRINGDHRYSTONE PROGRAM, 1'ST STRINGDHRYSTONE PROGRAM, 2'ND STRINGDhrystone(%s) time for %ld passes = %ld This machine benchmarks at %ld dhrystones/second (null)g1g1      AAAAAABBBBBB 0123456789ABCDEFDHRY wurde ganz normal erzeugt, DHRY280 habe ich mit einem f}r den Z280 gepatchten Compiler samt speziellem Optimizer und Laufzeitbibliothek gestrickt. Wenn es drauf ankommt, kann man also noch einiges an Leistung aus der CPU rausholen. [20:55] E0:RAMDISK>>dhry Dhrystone(1.1) time for 65500 passes = 80 This machine benchmarks at 818 dhrystones/second [20:57] E0:RAMDISK>>dhry280 Dhrystone(1.1) time for 65500 passes = 61 This machine benchmarks at 1073 dhrystones/second cu, Alexander Schmid