home *** CD-ROM | disk | FTP | other *** search
- { -----------------------------------------------------------------------------
-
- NOTICE:
-
- THESE MATERIALS are UNSUPPORTED by OSS! If you do not understand how to
- use them do not contact OSS for help! We will not teach you how to
- program in Pascal. If you find an error in these materials, feel free
- to SEND US A LETTER explaining the error, and how to fix it.
-
- THE BOTTOM LINE:
-
- Use it, enjoy it, but you are on your own when using these materials!
-
-
- DISCLAIMER:
-
- OSS makes no representations or warranties with respect to the contents
- hereof and specifically disclaim all warranties of merchantability or
- fitness for any particular purpose. This document is subject to change
- without notice.
-
- OSS provides these materials for use with Personal Pascal. Use them in
- any way you wish.
-
- -------------------------------------------------------------------------- }
-
-
- PROGRAM Dhrystone( output );
- (*
- * "DHRYSTONE" Benchmark Program
- *
- * Version: C/1
- * Date: 12/01/84, RESULTS updated 10/22/85
- * 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; One is
- * provided for CI-C86. Your compiler may be different.
- * 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.
- * Run: drynr; dryr
- *
- * Results: If you get any new machine/OS results, please send to:
- * BEGINihnp4,vax135,..END!houxm!vaximile!rer
- * and thanks to all that do. Space prevents listing
- * the names of those who have provided some of these
- * results.
- * Note: I order the list in increasing performance of the
- * "with registers" benchmark. If the compiler doesn't
- * provide register variables, then the benchmark
- * is the same for both REG and NOREG. I'm not going
- * to list a compiler in a better place because if it
- * had register variables it might do better. No
- * register variables is a big loss in my book.
- * PLEASE: Send complete information about the machine type,
- * clock speed, OS and C manufacturer/version. If
- * the machine is modified, tell me what was done.
- * Otherwise, I won't include it in this list. My
- * favorite flame on this subject was a machine that
- * was listed as an IBM PC/XT 8086-9.54Mhz. That must
- * have been some kind of co-processor board that ran
- * the benchmark, not the XT. Tell me what it was!
- *
- * MACHINE MICROPROCESSOR OPERATING COMPILER DHRYSTONES/SEC.
- * TYPE SYSTEM NO REG REGS
- * -------------------------- ------------ ----------- ---------------
- * IBM PC/XT 8088-4.77Mhz PC/IX cc 257 287
- * Cosmos 68000-8Mhz UniSoft cc 305 322
- * IBM PC/XT 8088-4.77Mhz VENIX/86 2.0 cc 297 324
- * IBM PC 8088-4.77Mhz MSDOS 2.0 b16cc 2.0 310 340
- * IBM PC 8088-4.77Mhz MSDOS 2.0 CI-C86 2.20M 390 390
- * IBM PC/XT 8088-4.77Mhz PCDOS 2.1 Lattice 2.15 403 - @
- * PDP-11/34 - UNIX V7M cc 387 438
- * Onyx C8002 Z8000-4Mhz IS/1 1.1 (V7) cc 476 511
- * ATT PC6300 8086-8Mhz MSDOS 2.11 b16cc 2.0 632 684
- * IBM PC/AT 80286-6Mhz PCDOS 3.0 CI-C86 2.1 666 684
- * Macintosh 68000-7.8Mhz 2M Mac Rom Mac C 32 bit int 694 704
- * Macintosh 68000-7.7Mhz - MegaMax C 2.0 661 709
- * NEC PC9801F 8086-8Mhz PCDOS 2.11 Lattice 2.15 768 - @
- * ATT PC6300 8086-8Mhz MSDOS 2.11 CI-C86 2.20M 769 769
- * ATT 3B2/300 WE32000-?Mhz UNIX 5.0.2 cc 735 806
- * IBM PC/AT 80286-6Mhz PCDOS 3.0 MS 3.0(large) 833 847 LM
- * VAX 11/750 - Unix 4.2bsd cc 862 877
- * Fast Mac 68000-7.7Mhz - MegaMax C 2.0 839 904 +
- * Macintosh 68000-7.8Mhz 2M Mac Rom Mac C 16 bit int 877 909 S
- * IRIS-1400 68010-10Mhz Unix System V cc 909 1000
- * IBM PC/AT 80286-6Mhz VENIX/86 2.1 cc 961 1000
- * IBM PC/AT 80286-6Mhz PCDOS 3.0 b16cc 2.0 943 1063
- * IBM PC/AT 80286-6Mhz PCDOS 3.0 MS 3.0(small) 1063 1086
- * VAX 11/750 - VMS VAX-11 C 2.0 958 1091
- * ATT PC7300 68010-10Mhz UNIX 5.2 cc 1041 1111
- * ATT PC6300+ 80286-6Mhz MSDOS 3.1 b16cc 2.0 1111 1219
- * Sun2/120 68010-10Mhz Sun 4.2BSD cc 1136 1219
- * IBM PC/AT 80286-6Mhz PCDOS 3.0 CI-C86 2.20M 1219 1219
- * MASSCOMP 500 68010-10MHz RTU V3.0 cc (V3.2) 1156 1238
- * Cyb DataMate 68010-12.5Mhz Uniplus 5.0 Unisoft cc 1162 1250
- * PDP 11/70 - UNIX 5.2 cc 1162 1250
- * IBM PC/AT 80286-6Mhz PCDOS 3.1 Lattice 2.15 1250 - @
- * IBM PC/AT 80286-7.5Mhz VENIX/86 2.1 cc 1190 1315 *
- * Sun2/120 68010-10Mhz Standalone cc 1219 1315
- * ATT 3B2/400 WE32100-?Mhz UNIX 5.2 cc 1315 1315
- * HP-110 8086-5.33Mhz MSDOS 2.11 Aztec-C 1282 1351 ?
- * IBM PC/AT 80286-6Mhz ? ? 1250 1388 ?
- * ATT PC6300+ 80286-6Mhz MSDOS 3.1 CI-C86 2.20M 1428 1428
- * Cyb DataMate 68010-12.5Mhz Uniplus 5.0 Unisoft cc 1470 1562 S
- * VAX 11/780 - UNIX 5.2 cc 1515 1562
- * MicroVAX-II - - - 1562 1612
- * ATT 3B20 - UNIX 5.2 cc 1515 1724
- * HP9000-500 B series CPU HP-UX 4.02 cc 1724 -
- * IBM PC/STD 80286-8Mhz ? ? 1724 1785
- * Gould PN6005 - UTX 1.1(4.2BSD) cc 1675 1964
- * VAX 11/785 - UNIX 5.2 cc 2083 2083
- * VAX 11/785 - VMS VAX-11 C 2.0 2083 2083
- * Pyramid 90x - OSx 2.3 cc 2272 2272
- * Pyramid 90x - OSx 2.5 cc 3125 3125
- * SUN 3/75 68020-16.67Mhz SUN 4.2 V3 cc 3333 3571
- * Sun 3/180 68020-16.67Mhz Sun 4.2 cc 3333 3846
- * MC 5400 68020-16.67MHz RTU V3.0 cc (V4.0) 3952 4054
- * SUN-3/160C 68020-16.67Mhz Sun3.0ALPHA1 Un*x 3333 4166
- * Gould PN9080 - UTX-32 1.1c cc - 4629
- * MC 5600/5700 68020-16.67MHz RTU V3.0 cc (V4.0) 4504 4746 %
- * VAX 8600 - VMS VAX-11 C 2.0 7142 7142
- * Amdahl 470 V/8 ? ? - 15015
- * Amdahl 580 - UTS 5.0 Rel 1.2 cc Ver. 1.5 23076 23076
- * Amdahl 5860 ? ? - 28355
- *
- * * 15Mhz crystal substituted for original 12Mhz;
- * + This Macintosh was upgraded from 128K to 512K in such a way that
- * the new 384K of memory is not slowed down by video generator accesses.
- * % Single processor; MC == MASSCOMP
- * & Seattle Telecom STD-286 board
- * @ vanilla Lattice compiler used with MicroPro standard library
- * S Shorts used instead of ints
- * LM Large Memory Model. (Otherwise, all 80x8x results are small model)
- * ? I don't trust results marked with '?'. These were sent to me with
- * either incomplete information, or with times that just don't make sense.
-
- * If anybody can confirm these figures, please respond.
- *
- **************************************************************************
- *
- * 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.
- *
- *)
-
- CONST
- (* Accuracy of timings and human fatigue controlled by next two lines *)
- LOOPS = 50000; (* Use this for slow or 16 bit machines *)
- (* LOOPS = 500000; (* Use this for faster machines *)
-
- (* We assume that the Pascal compiler can assign records *)
-
- (* define the granularity of your times(2) function (when used) *)
- (* HZ = 60; (* times(2) returns 1/60 second (most) *)
- (* HZ = 100; (* times(2) returns 1/100 second (WECo) *)
- HZ = 200; (* ST is different -gdf- *)
-
- TYPE
- Enumeration = ( Ident1, Ident2, Ident3, Ident4, Ident5 );
-
- OneToThirty = 1..30;
- OneToFifty = 1..50;
- CapitalLetter = char;
- String30 = PACKED ARRAY[ OneToThirty ] OF char;
- Array1Dim = ARRAY[ OneToFifty ] OF integer;
- Array2Dim = ARRAY[ OneToFifty ] OF Array1Dim;
-
- RecordPtr = ^RecordType;
- RecordType = RECORD
- PtrComp: RecordPtr;
- Discr: Enumeration;
- EnumComp: Enumeration;
- IntComp: OneToFifty;
- StringComp: String30;
- END;
-
- (*
- * Package 1
- *)
-
- VAR { Global variables }
- ssp: long_integer;
-
- IntGlob: integer;
- BoolGlob: boolean;
- Char1Glob: CapitalLetter;
- Char2Glob: CapitalLetter;
- Array1Glob: Array1Dim;
- Array2Glob: Array2Dim;
- PtrGlb: RecordPtr;
- PtrGlbNext: RecordPtr;
-
- FUNCTION time: long_integer;
-
- TYPE
- long_pointer = ^long_integer;
-
- VAR
- hz_200: RECORD
- CASE boolean OF
- true: ( l: long_integer );
- false: ( p: long_pointer );
- END;
-
- BEGIN
- hz_200.l := $4ba;
- (*$P-*)
- time := hz_200.p^;
- (*$P=*)
- END;
-
- PROCEDURE Proc2( VAR IntParIO: OneToFifty );
-
- VAR
- IntLoc: OneToFifty;
- EnumLoc: Enumeration;
-
- BEGIN { Proc2 }
- IntLoc := IntParIO + 10;
- REPEAT
- IF Char1Glob = 'A' THEN
- BEGIN
- IntLoc := IntLoc - 1;
- IntParIO := IntLoc - IntGlob;
- EnumLoc := Ident1;
- END
- UNTIL EnumLoc = Ident1;
- END; { Proc2 }
-
- PROCEDURE Proc7( IntParI1, IntParI2: OneToFifty; VAR IntParOut: OneToFifty );
-
- VAR
- IntLoc: OneToFifty;
-
- BEGIN { Proc7 }
- IntLoc := IntParI1 + 2;
- IntParOut := IntParI2 + IntLoc;
- END; { Proc7 }
-
- PROCEDURE Proc3( VAR PtrParOut: RecordPtr );
-
- BEGIN { Proc3 }
- IF PtrGlb <> nil THEN
- PtrParOut := PtrGlb^.PtrComp
- ELSE
- IntGlob := 100;
- Proc7( 10, IntGlob, PtrGlb^.IntComp );
- END; { Proc3 }
-
- PROCEDURE Proc4;
-
- VAR
- BoolLoc: boolean;
-
- BEGIN { Proc4 }
- BoolLoc := (Char1Glob = 'A');
- BoolLoc := BoolLoc OR BoolGlob;
- Char2Glob := 'B';
- END; { Proc4 }
-
- PROCEDURE Proc5;
-
- BEGIN { Proc5 }
- Char1Glob := 'A';
- BoolGlob := false;
- END; { Proc5 }
-
- FUNCTION Func1( CharPar1, CharPar2: CapitalLetter ): Enumeration;
-
- VAR
- CharLoc1,
- CharLoc2: CapitalLetter;
-
- BEGIN { Func1 }
- CharLoc1 := CharPar1;
- CharLoc2 := CharLoc1;
- IF CharLoc2 <> CharPar2 THEN
- Func1 := Ident1
- ELSE
- Func1 := Ident2;
- END; { Func1 }
-
- FUNCTION Func2( VAR StrParI1, StrParI2: String30 ): boolean;
-
- VAR
- IntLoc: OneToThirty;
- CharLoc: CapitalLetter;
-
- BEGIN { Func2 }
- IntLoc := 1;
- WHILE IntLoc <= 1 DO
- IF Func1(StrParI1[IntLoc], StrParI2[IntLoc+1]) = Ident1 THEN
- BEGIN
- CharLoc := 'A';
- IntLoc := IntLoc + 1;
- END;
- IF (CharLoc >= 'W') AND (CharLoc <= 'Z') THEN
- IntLoc := 7;
- IF CharLoc = 'X' THEN
- Func2 := true
- ELSE
- BEGIN
- IF StrParI1 > StrParI2 THEN
- BEGIN
- IntLoc := IntLoc + 7;
- Func2 := true;
- END
- ELSE
- Func2 := false;
- END
- END; { Func2 }
-
- FUNCTION Func3( EnumParIn: Enumeration ): boolean;
-
- VAR
- EnumLoc: Enumeration;
-
- BEGIN
- EnumLoc := EnumParIn;
- Func3 := (EnumLoc = Ident3);
- END; { Func3 }
-
- PROCEDURE Proc6( EnumParIn: Enumeration; VAR EnumParOut: Enumeration );
-
- BEGIN
- EnumParOut := EnumParIn;
- IF NOT Func3(EnumParIn) THEN
- EnumParOut := Ident4;
- CASE EnumParIn OF
- Ident1: EnumParOut := Ident1;
- Ident2: IF IntGlob > 100 THEN
- EnumParOut := Ident1
- ELSE
- EnumParOut := Ident4;
- Ident3: EnumParOut := Ident2;
- Ident4: ;
- Ident5: EnumParOut := Ident3;
- END; { CASE }
- END; { Proc6 }
-
- PROCEDURE Proc8( VAR Array1Par: Array1Dim; VAR Array2Par: Array2Dim;
- IntParI1, IntParI2: OneToFifty );
-
- VAR
- IntLoc: OneToFifty;
- IntIndex: OneToFifty;
-
- BEGIN { Proc8 }
- IntLoc := IntParI1 + 5;
- Array1Par[IntLoc] := IntParI2;
- Array1Par[IntLoc+1] := Array1Par[IntLoc];
- Array1Par[IntLoc+30] := IntLoc;
- FOR IntIndex := IntLoc TO IntLoc+1 DO
- Array2Par[IntLoc][IntIndex] := IntLoc;
- Array2Par[IntLoc][IntLoc-1] := Array2Par[IntLoc][IntLoc-1] + 1;
- Array2Par[IntLoc+20][IntLoc] := Array1Par[IntLoc];
- IntGlob := 5;
- END; { Proc8 }
-
- PROCEDURE Proc1( PtrParIn: RecordPtr );
-
- BEGIN
- PtrParIn^.PtrComp^ := PtrGlb^;
- PtrParIn^.IntComp := 5;
- PtrParIn^.PtrComp^.IntComp := PtrParIn^.IntComp;
- PtrParIn^.PtrComp^.PtrComp := PtrParIn^.PtrComp;
- Proc3( PtrParIn^.PtrComp^.PtrComp );
- IF PtrParIn^.PtrComp^.Discr = Ident1 THEN
- BEGIN
- PtrParIn^.PtrComp^.IntComp := 6;
- Proc6( PtrParIn^.EnumComp, PtrParIn^.PtrComp^.EnumComp );
- PtrParIn^.PtrComp^.PtrComp := PtrGlb^.PtrComp;
- Proc7( PtrParIn^.PtrComp^.IntComp, 10, PtrParIn^.PtrComp^.IntComp );
- END
- ELSE
- PtrParIn^ := PtrParIn^.PtrComp^;
- END; { Proc1 }
-
- PROCEDURE Proc0;
-
- VAR
- IntLoc1: OneToFifty;
- IntLoc2: OneToFifty;
- IntLoc3: OneToFifty;
- CharLoc: CapitalLetter;
- CharIndex: CapitalLetter;
- EnumLoc: Enumeration;
- String1Loc: String30;
- String2Loc: String30;
-
- starttime,
- benchtime,
- nulltime: long_integer;
- i: long_integer;
-
- BEGIN
- starttime := time;
- i := 0;
- WHILE i < LOOPS DO
- i := i + 1;
- nulltime := time - starttime; (* Computes overhead of looping *)
-
- new( PtrGlbNext );
- new( PtrGlb );
- PtrGlb^.PtrComp := PtrGlbNext;
- PtrGlb^.Discr := Ident1;
- PtrGlb^.EnumComp := Ident3;
- PtrGlb^.IntComp := 40;
- PtrGlb^.StringComp := 'DHRYSTONE PROGRAM, SOME STRING';
-
- (*****************
- -- Start Timer --
- *****************)
- starttime := time;
- i := 0;
- WHILE i < LOOPS DO
- BEGIN
- Proc5;
- Proc4;
- IntLoc1 := 2;
- IntLoc2 := 3;
- String2Loc := 'DHRYSTONE PROGRAM, 2''ND STRING';
- EnumLoc := Ident2;
- BoolGlob := NOT Func2(String1Loc, String2Loc);
- WHILE IntLoc1 < IntLoc2 DO
- BEGIN
- IntLoc3 := 5 * IntLoc1 - IntLoc2;
- Proc7( IntLoc1, IntLoc2, IntLoc3 );
- IntLoc1 := IntLoc1 + 1;
- END;
- Proc8( Array1Glob, Array2Glob, IntLoc1, IntLoc3 );
- Proc1( PtrGlb );
- FOR CharIndex := 'A' TO Char2Glob DO
- IF EnumLoc = Func1(CharIndex, 'C') THEN
- Proc6(Ident1, EnumLoc);
- IntLoc3 := IntLoc2 * IntLoc1;
- IntLoc2 := IntLoc3 DIV IntLoc1;
- IntLoc2 := 7 * (IntLoc3 - IntLoc2) - IntLoc1;
- Proc2( IntLoc1 );
-
- i := i + 1;
- END;
- (*****************
- -- Stop Timer --
- *****************)
- benchtime := time - starttime - nulltime;
- writeln( 'Dhrystone time for ', LOOPS, ' passes :=', benchtime/HZ:15:2 );
- writeln( 'This machine benchmarks at ', LOOPS*(HZ/benchtime):15:2,
- ' dhrystones/second' );
- END; { Proc0 }
-
- FUNCTION Super( x: long_integer ): long_integer;
- GEMDOS( $20 );
-
- BEGIN { Main routine }
- ssp := Super( 0 );
- Proc0;
- ssp := Super( ssp );
- END.
-