home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / pc / source / dhrys.zoo / dhrys.3 < prev    next >
Encoding:
Text File  |  1990-02-21  |  56.5 KB  |  1,309 lines

  1.  
  2. #! /bin/sh
  3. # This is a shell archive, meaning:
  4. # 1. Remove everything above the #! /bin/sh line.
  5. # 2. Save the resulting text in a file.
  6. # 3. Execute the file with /bin/sh (not csh) to create:
  7. #    dhry.h
  8. #    dhry.p
  9. # This archive created: Wed Feb 14 19:32:28 1990
  10. export PATH; PATH=/bin:/usr/bin:$PATH
  11. echo shar: "extracting 'dhry.h'" '(18533 characters)'
  12. if test -f 'dhry.h'
  13. then
  14.     echo shar: "will not over-write existing file 'dhry.h'"
  15. else
  16. sed 's/^X//' << \SHAR_EOF > 'dhry.h'
  17. X/*
  18. X ****************************************************************************
  19. X *
  20. X *                   "DHRYSTONE" Benchmark Program
  21. X *                   -----------------------------
  22. X *                                                                            
  23. X *  Version:    C, Version 2.1
  24. X *                                                                            
  25. X *  File:       dhry.h (part 1 of 3)
  26. X *
  27. X *  Date:       May 25, 1988
  28. X *
  29. X *  Author:     Reinhold P. Weicker
  30. X *                      Siemens AG, E STE 35
  31. X *                      Postfach 3240
  32. X *                      8520 Erlangen
  33. X *                      Germany (West)
  34. X *                              Phone:  [xxx-49]-9131-7-20330
  35. X *                                      (8-17 Central European Time)
  36. X *                              Usenet: ..!mcvax!unido!estevax!weicker
  37. X *
  38. X *              Original Version (in Ada) published in
  39. X *              "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
  40. X *              pp. 1013 - 1030, together with the statistics
  41. X *              on which the distribution of statements etc. is based.
  42. X *
  43. X *              In this C version, the following C library functions are used:
  44. X *              - strcpy, strcmp (inside the measurement loop)
  45. X *              - printf, scanf (outside the measurement loop)
  46. X *              In addition, Berkeley UNIX system calls "times ()" or "time ()"
  47. X *              are used for execution time measurement. For measurements
  48. X *              on other systems, these calls have to be changed.
  49. X *
  50. X *  Collection of Results:
  51. X *              Reinhold Weicker (address see above) and
  52. X *              
  53. X *              Rick Richardson
  54. X *              PC Research. Inc.
  55. X *              94 Apple Orchard Drive
  56. X *              Tinton Falls, NJ 07724
  57. X *                      Phone:  (201) 389-8963 (9-17 EST)               
  58. X *                      Usenet: ...!uunet!pcrat!rick
  59. X *
  60. X *      Please send results to Rick Richardson and/or Reinhold Weicker.
  61. X *      Complete information should be given on hardware and software used.
  62. X *      Hardware information includes: Machine type, CPU, type and size
  63. X *      of caches; for microprocessors: clock frequency, memory speed
  64. X *      (number of wait states).
  65. X *      Software information includes: Compiler (and runtime library)
  66. X *      manufacturer and version, compilation switches, OS version.
  67. X *      The Operating System version may give an indication about the
  68. X *      compiler; Dhrystone itself performs no OS calls in the measurement loop.
  69. X *
  70. X *      The complete output generated by the program should be mailed
  71. X *      such that at least some checks for correctness can be made.
  72. X *
  73. X ***************************************************************************
  74. X *
  75. X *  History:    This version C/2.1 has been made for two reasons:
  76. X *
  77. X *              1) There is an obvious need for a common C version of
  78. X *              Dhrystone, since C is at present the most popular system
  79. X *              programming language for the class of processors
  80. X *              (microcomputers, minicomputers) where Dhrystone is used most.
  81. X *              There should be, as far as possible, only one C version of
  82. X *              Dhrystone such that results can be compared without
  83. X *              restrictions. In the past, the C versions distributed
  84. X *              by Rick Richardson (Version 1.1) and by Reinhold Weicker
  85. X *              had small (though not significant) differences.
  86. X *
  87. X *              2) As far as it is possible without changes to the Dhrystone
  88. X *              statistics, optimizing compilers should be prevented from
  89. X *              removing significant statements.
  90. X *
  91. X *              This C version has been developed in cooperation with
  92. X *              Rick Richardson (Tinton Falls, NJ), it incorporates many
  93. X *              ideas from the "Version 1.1" distributed previously by
  94. X *              him over the UNIX network Usenet.
  95. X *              I also thank Chaim Benedelac (National Semiconductor),
  96. X *              David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
  97. X *              Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
  98. X *              for their help with comments on earlier versions of the
  99. X *              benchmark.
  100. X *
  101. X *  Changes:    In the initialization part, this version follows mostly
  102. X *              Rick Richardson's version distributed via Usenet, not the
  103. X *              version distributed earlier via floppy disk by Reinhold Weicker.
  104. X *              As a concession to older compilers, names have been made
  105. X *              unique within the first 8 characters.
  106. X *              Inside the measurement loop, this version follows the
  107. X *              version previously distributed by Reinhold Weicker.
  108. X *
  109. X *              At several places in the benchmark, code has been added,
  110. X *              but within the measurement loop only in branches that 
  111. X *              are not executed. The intention is that optimizing compilers
  112. X *              should be prevented from moving code out of the measurement
  113. X *              loop, or from removing code altogether. Since the statements
  114. X *              that are executed within the measurement loop have NOT been
  115. X *              changed, the numbers defining the "Dhrystone distribution"
  116. X *              (distribution of statements, operand types and locality)
  117. X *              still hold. Except for sophisticated optimizing compilers,
  118. X *              execution times for this version should be the same as
  119. X *              for previous versions.
  120. X *              
  121. X *              Since it has proven difficult to subtract the time for the
  122. X *              measurement loop overhead in a correct way, the loop check
  123. X *              has been made a part of the benchmark. This does have
  124. X *              an impact - though a very minor one - on the distribution
  125. X *              statistics which have been updated for this version.
  126. X *
  127. X *              All changes within the measurement loop are described
  128. X *              and discussed in the companion paper "Rationale for
  129. X *              Dhrystone version 2".
  130. X *
  131. X *              Because of the self-imposed limitation that the order and
  132. X *              distribution of the executed statements should not be
  133. X *              changed, there are still cases where optimizing compilers
  134. X *              may not generate code for some statements. To a certain
  135. X *              degree, this is unavoidable for small synthetic benchmarks.
  136. X *              Users of the benchmark are advised to check code listings
  137. X *              whether code is generated for all statements of Dhrystone.
  138. X *
  139. X *              Version 2.1 is identical to version 2.0 distributed via
  140. X *              the UNIX network Usenet in March 1988 except that it corrects
  141. X *              some minor deficiencies that were found by users of version 2.0.
  142. X *              The only change within the measurement loop is that a
  143. X *              non-executed "else" part was added to the "if" statement in
  144. X *              Func_3, and a non-executed "else" part removed from Proc_3.
  145. X *
  146. X ***************************************************************************
  147. X *
  148. X * Defines:     The following "Defines" are possible:
  149. X *              -DREG=register          (default: Not defined)
  150. X *                      As an approximation to what an average C programmer
  151. X *                      might do, the "register" storage class is applied
  152. X *                      (if enabled by -DREG=register)
  153. X *                      - for local variables, if they are used (dynamically)
  154. X *                        five or more times
  155. X *                      - for parameters if they are used (dynamically)
  156. X *                        six or more times
  157. X *                      Note that an optimal "register" strategy is
  158. X *                      compiler-dependent, and that "register" declarations
  159. X *                      do not necessarily lead to faster execution.
  160. X *              -DNOSTRUCTASSIGN        (default: Not defined)
  161. X *                      Define if the C compiler does not support
  162. X *                      assignment of structures.
  163. X *              -DNOENUMS               (default: Not defined)
  164. X *                      Define if the C compiler does not support
  165. X *                      enumeration types.
  166. X *              -DTIMES                 (default)
  167. X *              -DTIME
  168. X *                      The "times" function of UNIX (returning process times)
  169. X *                      or the "time" function (returning wallclock time)
  170. X *                      is used for measurement. 
  171. X *                      For single user machines, "time ()" is adequate. For
  172. X *                      multi-user machines where you cannot get single-user
  173. X *                      access, use the "times ()" function. If you have
  174. X *                      neither, use a stopwatch in the dead of night.
  175. X *                      "printf"s are provided marking the points "Start Timer"
  176. X *                      and "Stop Timer". DO NOT use the UNIX "time(1)"
  177. X *                      command, as this will measure the total time to
  178. X *                      run this program, which will (erroneously) include
  179. X *                      the time to allocate storage (malloc) and to perform
  180. X *                      the initialization.
  181. X *              -DHZ=nnn
  182. X *                      In Berkeley UNIX, the function "times" returns process
  183. X *                      time in 1/HZ seconds, with HZ = 60 for most systems.
  184. X *                      CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY
  185. X *                      A VALUE.
  186. X *
  187. X ***************************************************************************
  188. X *
  189. X *  Compilation model and measurement (IMPORTANT):
  190. X *
  191. X *  This C version of Dhrystone consists of three files:
  192. X *  - dhry.h (this file, containing global definitions and comments)
  193. X *  - dhry_1.c (containing the code corresponding to Ada package Pack_1)
  194. X *  - dhry_2.c (containing the code corresponding to Ada package Pack_2)
  195. X *
  196. X *  The following "ground rules" apply for measurements:
  197. X *  - Separate compilation
  198. X *  - No procedure merging
  199. X *  - Otherwise, compiler optimizations are allowed but should be indicated
  200. X *  - Default results are those without register declarations
  201. X *  See the companion paper "Rationale for Dhrystone Version 2" for a more
  202. X *  detailed discussion of these ground rules.
  203. X *
  204. X *  For 16-Bit processors (e.g. 80186, 80286), times for all compilation
  205. X *  models ("small", "medium", "large" etc.) should be given if possible,
  206. X *  together with a definition of these models for the compiler system used.
  207. X *
  208. X **************************************************************************
  209. X *
  210. X *  Dhrystone (C version) statistics:
  211. X *
  212. X *  [Comment from the first distribution, updated for version 2.
  213. X *   Note that because of language differences, the numbers are slightly
  214. X *   different from the Ada version.]
  215. X *
  216. X *  The following program contains statements of a high level programming
  217. X *  language (here: C) in a distribution considered representative:           
  218. X *
  219. X *    assignments                  52 (51.0 %)
  220. X *    control statements           33 (32.4 %)
  221. X *    procedure, function calls    17 (16.7 %)
  222. X *
  223. X *  103 statements are dynamically executed. The program is balanced with
  224. X *  respect to the three aspects:                                             
  225. X *
  226. X *    - statement type
  227. X *    - operand type
  228. X *    - operand locality
  229. X *         operand global, local, parameter, or constant.                     
  230. X *
  231. X *  The combination of these three aspects is balanced only approximately.    
  232. X *
  233. X *  1. Statement Type:                                                        
  234. X *  -----------------             number
  235. X *
  236. X *     V1 = V2                     9
  237. X *       (incl. V1 = F(..)
  238. X *     V = Constant               12
  239. X *     Assignment,                 7
  240. X *       with array element
  241. X *     Assignment,                 6
  242. X *       with record component
  243. X *                                --
  244. X *                                34       34
  245. X *
  246. X *     X = Y +|-|"&&"|"|" Z        5
  247. X *     X = Y +|-|"==" Constant     6
  248. X *     X = X +|- 1                 3
  249. X *     X = Y *|/ Z                 2
  250. X *     X = Expression,             1
  251. X *           two operators
  252. X *     X = Expression,             1
  253. X *           three operators
  254. X *                                --
  255. X *                                18       18
  256. X *
  257. X *     if ....                    14
  258. X *       with "else"      7
  259. X *       without "else"   7
  260. X *           executed        3
  261. X *           not executed    4
  262. X *     for ...                     7  |  counted every time
  263. X *     while ...                   4  |  the loop condition
  264. X *     do ... while                1  |  is evaluated
  265. X *     switch ...                  1
  266. X *     break                       1
  267. X *     declaration with            1
  268. X *       initialization
  269. X *                                --
  270. X *                                34       34
  271. X *
  272. X *     P (...)  procedure call    11
  273. X *       user procedure      10
  274. X *       library procedure    1
  275. X *     X = F (...)
  276. X *             function  call      6
  277. X *       user function        5                                         
  278. X *       library function     1                                               
  279. X *                                --                                          
  280. X *                                17       17
  281. X *                                        ---
  282. X *                                        103
  283. X *
  284. X *    The average number of parameters in procedure or function calls
  285. X *    is 1.82 (not counting the function values aX *
  286. X *
  287. X *  2. Operators
  288. X *  ------------
  289. X *                          number    approximate
  290. X *                                    percentage
  291. X *
  292. X *    Arithmetic             32          50.8                                 
  293. X *
  294. X *       +                     21          33.3                              
  295. X *       -                      7          11.1                              
  296. X *       *                      3           4.8
  297. X *       / (int div)            1           1.6
  298. X *
  299. X *    Comparison             27           42.8
  300. X *
  301. X *       ==                     9           14.3
  302. X *       /=                     4            6.3
  303. X *       >                      1            1.6
  304. X *       <                      3            4.8
  305. X *       >=                     1            1.6
  306. X *       <=                     9           14.3
  307. X *
  308. X *    Logic                   4            6.3
  309. X *
  310. X *       && (AND-THEN)          1            1.6
  311. X *       |  (OR)                1            1.6
  312. X *       !  (NOT)               2            3.2
  313. X * 
  314. X *                           --          -----
  315. X *                           63          100.1
  316. X *
  317. X *
  318. X *  3. Operand Type (counted once per operand reference):
  319. X *  ---------------
  320. X *                          number    approximate
  321. X *                                    percentage
  322. X *
  323. X *     Integer               175        72.3 %
  324. X *     Character              45        18.6 %
  325. X *     Pointer                12         5.0 %
  326. X *     String30                6         2.5 %
  327. X *     Array                   2         0.8 %
  328. X *     Record                  2         0.8 %
  329. X *                           ---       -------
  330. X *                           242       100.0 %
  331. X *
  332. X *  When there is an access path leading to the final operand (e.g. a record
  333. X *  component), only the final data type on the access path is counted.       
  334. X *
  335. X *
  336. X *  4. Operand Locality:                                                      
  337. X *  -------------------
  338. X *                                number    approximate
  339. X *                                          percentage
  340. X *
  341. X *     local variable              114        47.1 %
  342. X *     global variable              22         9.1 %
  343. X *     parameter                    45        18.6 %
  344. X *        value                        23         9.5 %
  345. X *        reference                    22         9.1 %
  346. X *     function result               6         2.5 %
  347. X *     constant                     55        22.7 %
  348. X *                                 ---       -------
  349. X *                                 242       100.0 %
  350. X *
  351. X *
  352. X *  The program does not compute anything meaningful, but it is syntactically
  353. X *  and semantically correct. All variables have a value assigned to them
  354. X *  before they are used as a source operand.
  355. X *
  356. X *  There has been no explicit effort to account for the effects of a
  357. X *  cache, or to balance the use of long or short displacements for code or
  358. X *  data.
  359. X *
  360. X ***************************************************************************
  361. X */
  362. X
  363. X/* Compiler and system dependent definitions: */
  364. X
  365. X#ifndef TIME
  366. X#undef TIMES
  367. X#define TIMES
  368. X#endif
  369. X                /* Use times(2) time function unless    */
  370. X                /* explicitly defined otherwise         */
  371. X
  372. X#ifdef MSC_CLOCK
  373. X#undef HZ
  374. X#undef TIMES
  375. X#include <time.h>
  376. X#define HZ    CLK_TCK
  377. X#endif
  378. X        /* Use Microsoft C hi-res clock */
  379. X
  380. X#ifdef TIMES
  381. X#include <sys/types.h>
  382. X#include <sys/times.h>
  383. X                /* for "times" */
  384. X#endif
  385. X
  386. X#define Mic_secs_Per_Second     1000000.0
  387. X                /* Berkeley UNIX C returns process times in seconds/HZ */
  388. X
  389. X#ifdef  NOSTRUCTASSIGN
  390. X#define structassign(d, s)      memcpy(&(d), &(s), sizeof(d))
  391. X#else
  392. X#define structassign(d, s)      d = s
  393. X#endif
  394. X
  395. X#ifdef  NOENUM
  396. X#define Ident_1 0
  397. X#define Ident_2 1
  398. X#define Ident_3 2
  399. X#define Ident_4 3
  400. X#define Ident_5 4
  401. X  typedef int   Enumeration;
  402. X#else
  403. X  typedef       enum    {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
  404. X                Enumeration;
  405. X#endif
  406. X        /* for boolean and enumeration types in Ada, Pascal */
  407. X
  408. X/* General definitions: */
  409. X
  410. X#include <stdio.h>
  411. X                /* for strcpy, strcmp */
  412. X
  413. X#define Null 0 
  414. X                /* Value of a Null pointer */
  415. X#define true  1
  416. X#define false 0
  417. X
  418. Xtypedef int     One_Thirty;
  419. Xtypedef int     One_Fifty;
  420. Xtypedef char    Capital_Letter;
  421. Xtypedef int     Boolean;
  422. Xtypedef char    Str_30 [31];
  423. Xtypedef int     Arr_1_Dim [50];
  424. Xtypedef int     Arr_2_Dim [50] [50];
  425. X
  426. Xtypedef struct record 
  427. X    {
  428. X    struct record *Ptr_Comp;
  429. X    Enumeration    Discr;
  430. X    union {
  431. X          struct {
  432. X                  Enumeration Enum_Comp;
  433. X                  int         Int_Comp;
  434. X                  char        Str_Comp [31];
  435. X                  } var_1;
  436. X          struct {
  437. X                  Enumeration E_Comp_2;
  438. X                  char        Str_2_Comp [31];
  439. X                  } var_2;
  440. X          struct {
  441. X                  char        Ch_1_Comp;
  442. X                  char        Ch_2_Comp;
  443. X                  } var_3;
  444. X          } variant;
  445. X      } Rec_Type, *Rec_Pointer;
  446. X
  447. X
  448. SHAR_EOF
  449. if test 18533 -ne "`wc -c < 'dhry.h'`"
  450. then
  451.     echo shar: "error transmitting 'dhry.h'" '(should have been 18533 characters)'
  452. fi
  453. fi
  454. echo shar: "extracting 'dhry.p'" '(37108 characters)'
  455. if test -f 'dhry.p'
  456. then
  457.     echo shar: "will not over-write existing file 'dhry.p'"
  458. else
  459. sed 's/^X//' << \SHAR_EOF > 'dhry.p'
  460. X(*
  461. X ****************************************************************************
  462. X *
  463. X *                   "DHRYSTONE" Benchmark Program
  464. X *                   -----------------------------
  465. X *                                                                            
  466. X *  Version:    Pascal, Version 2.1
  467. X *                                                                            
  468. X *  File:       dhry.p
  469. X *
  470. X *  Date:       May 25, 1988
  471. X *
  472. X *  Author:     Reinhold P. Weicker
  473. X *                      Siemens AG, E STE 35
  474. X *                      Postfach 3240
  475. X *                      8520 Erlangen
  476. X *                      Germany (West)
  477. X *                              Phone:  [xxx-49]-9131-7-20330
  478. X *                                      (8-17 Central European Time)
  479. X *                              Usenet: ..!mcvax!unido!estevax!weicker
  480. X *
  481. X *              Original Version (in Ada) published in
  482. X *              "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
  483. X *              pp. 1013 - 1030, together with the statistics
  484. X *              on which the distribution of statements etc. is based,
  485. X *
  486. X *              This version uses calls to the Pascal runtime library of the
  487. X *              Berkeley UNIX system (4.3 bsd) for time measurement.
  488. X *              For measurements on other systems, these calls need to be
  489. X *              modified.                                
  490. X *                                                                           
  491. X *  Collection of Results:
  492. X *              Reinhold Weicker (address see above) and
  493. X *              
  494. X *              Rick Richardson
  495. X *              PC Research. Inc.
  496. X *              94 Apple Orchard Drive
  497. X *              Tinton Falls, NJ 07724
  498. X *                      Phone:  (201) 834-1378 (9-17 EST)               
  499. X *                      Usenet: ...!seismo!uunet!pcrat!rick
  500. X *
  501. X *      Please send results to Rick Richardson and/or Reinhold Weicker.
  502. X *      Complete information should be given on hardware and software used.
  503. X *      Hardware information includes: Machine type, CPU, type and size
  504. X *      of caches; for microprocessors: clock frequency, memory speed
  505. X *      (number of wait states).
  506. X *      Software information includes: Compiler (and runtime library)
  507. X *      manufacturer and version, compilation switches, OS version.
  508. X *      The Operating System version may give an indication about the
  509. X *      compiler; Dhrystone itself performs no OS calls in the measurement loop.
  510. X *
  511. X *      The complete output generated by the program should be mailed
  512. X *      such that at least some checks for correctness can be made.
  513. X *
  514. X ****************************************************************************
  515. X *
  516. X *  History:    This version Pascal/2.1 has been made for two reasons:
  517. X *
  518. X *              1) There is a need for a common Pascal version of
  519. X *              Dhrystone. Although translation from the published (Ada)
  520. X *              version to Pascal is straightforward in most aspects,
  521. X *              there are cases where it may not be obvious to everyone.
  522. X *              There should be, as far as possible, only one Pascal version
  523. X *              of Dhrystone such that results can be compared without
  524. X *              restrictions. Also, a Pascal version of Dhrystone has not yet
  525. X *              found a network distribution comparable to the C version
  526. X *              (version 1.1) distributed by Rick Richardson.
  527. X *              
  528. X *              2) As far as it is possible without changes to the Dhrystone
  529. X *              statistics, optimizing compilers should be prevented from
  530. X *              removing significant statements.
  531. X *
  532. X *              This Pascal version 2.1 has been made consistent with the
  533. X *              C version 2.1; therefore the acknowledgments for the C version
  534. X *              are due for the Pascal version as well: I thank
  535. X *              Rick Richardson (Tinton Falls, NJ), Chaim Benedelac (Nat.
  536. X *              Semi.), David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
  537. X *              Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
  538. X *              for their help with comments on earlier versions of the
  539. X *              benchmark.
  540. X *
  541. X *  Changes:    In the initialization part, this version differs 
  542. X *              from the Pascal version previously distributed by Reinhold
  543. X *              Weicker, the number of runs through Dhrystone is obtained
  544. X *              interactively from the terminal. Output of the result 
  545. X *              has been changed to conform to the C version (2.1).
  546. X *              The changes in the initialization part and in the printing
  547. X *              of the result have no impact on performance measurement 
  548. X *              since they are outside the measaurement loop.
  549. X *              
  550. X *              Inside the measurement loop, this version follows the
  551. X *              version previously distributed by Reinhold Weicker.
  552. X *              As a correction to the published version, a statement
  553. X *              initializing Array2Glob [8,7] (outside the measurement
  554. X *              loop) has been added. Otherwise, this array element would
  555. X *              have an undefined value.
  556. X *
  557. X *              At several places in the benchmark, code has been added,
  558. X *              but within the measurement loop only in branches that 
  559. X *              are not executed. The intention is that optimizing compilers
  560. X *              should be prevented from moving code out of the measurement
  561. X *              loop, or from removing code altogether. Since the statements
  562. X *              that are executed within the measurement loop have NOT been
  563. X *              changed, all numbers defining the "Dhrystone distribution"
  564. X *              (distribution of statements, operand types and locality)
  565. X *              still hold. Except for sophisticated optimizing compilers,
  566. X *              execution times for this version should be the same as
  567. X *              for previous versions.
  568. X *
  569. X *              Since it has proven difficult to subtract the time for the
  570. X *              measurement loop overhead in a correct way, the loop check
  571. X *              has been made a part of the benchmark. This does have
  572. X *              an impact - though a very minor one - on the distribution
  573. X *              statistics which have been updated for this version.
  574. X *
  575. X *              All changes within the measurement loop are described
  576. X *              and discussed in the companion paper "Rationale for
  577. X *              Dhrystone version 2".
  578. X *
  579. X *              Because of the self-imposed limitation that the order and
  580. X *              distribution of the executed statements should not be
  581. X *              changed, there are still cases where optimizing compilers
  582. X *              may not generate code for some statements. To a certain
  583. X *              degree, this is unavoidable for small synthetic benchmarks.
  584. X *              Users of the benchmark are advised to check code listings
  585. X *              whether code is generated for all statements of Dhrystone.
  586. X *
  587. X *              Version 2.1 is identical to version 2.0 distributed via
  588. X *              the UNIX network Usenet in March 1988 except that it corrects
  589. X *              some minor deficiencies that were found by users of version 2.0.
  590. X *              The only change within the measurement loop is that a
  591. X *              non-executed "else" part was added to the "if" statement in
  592. X *              Func3, and a non-executed "else" part removed from Proc3.
  593. X *
  594. X ***************************************************************************
  595. X *
  596. X *  Compilation model and measurement (IMPORTANT):
  597. X *
  598. X *  This program contains the Dhrystone program, including measurement setup,
  599. X *  in one file. The original (Ada) program contained three packages,
  600. X *  - a package with global type definitions,
  601. X *  - Pack_1, containing the main program (Proc_0 in Ada) and procedures
  602. X *            Proc_1, ... , Proc_5,
  603. X *  - Pack_2, containing Proc_6, ... , Proc_8, Func_1, ..., Func_3.
  604. X *  Since ISO/ANSI Standard Pascal provides no means to express separate
  605. X *  compilation (although many Pascal implementations provide such a feature),
  606. X *  it is not possible to formulate a portable Pascal version with the program
  607. X *  in several modules, corresponding more closely to the Ada and C versions.
  608. X *  Therefore, no attempt has been made to construct a Pascal version with
  609. X *  the program consisting of several modules.
  610. X *                                                                           
  611. X *  This difference may impact execution time because the compiler can
  612. X *  perform more data flow analysis for a single-module program;
  613. X *  sophisticated compilers may be able to suppress code generation for
  614. X *  some parts of the program.
  615. X *  Users should check machine code listings generated by the compiler
  616. X *  to ensure that code is generated for all parts of the program.
  617. X *
  618. X *  The following "ground rules" apply for measurements:
  619. X *  - No procedure merging
  620. X *  - Otherwise, compiler optimizations are allowed but should be indicated
  621. X *  See the companion paper "Rationale for Dhrystone Version 2" for a more
  622. X *  detailed discussion of these ground rules.
  623. X *
  624. X *  For 16-Bit processors (e.g. 80x86), times for all compilation models
  625. X *  ("small", "medium", "large") should be given if possible, together
  626. X *  with a definition of these models for the compiler system used.
  627. X *
  628. X **************************************************************************
  629. X *
  630. X *  Dhrystone (Pascal version) statistics:
  631. X *
  632. X *  [Comment from the first distribution by Reinhold Weicker,
  633. X *   the distribution statistics have been updated for Version 2.1.
  634. X *   Note that because of language differences, the numbers are different
  635. X *   from the Ada version. The main difference is that the variables that
  636. X *   are local variables of "Proc_0" (Ada) or "main" (C) are global
  637. X *   variables in the Pascal version.]
  638. X *                                                                           
  639. X *  The following program contains statements of a high level programming    
  640. X *  language (here: Pascal) in a distribution considered representative:     
  641. X *                                                                           
  642. X *    assignments                  58
  643. X *    control statements           28
  644. X *    procedure, function calls    15
  645. X *                                                                           
  646. X *  100 statements are dynamically executed. The program is balanced with    
  647. X *  respect to the three aspects:                                            
  648. X *                                                                           
  649. X *    - statement type                                                       
  650. X *    - operand type (for simple data types)                                 
  651. X *    - operand access                                                       
  652. X *         operand global, local, parameter, or constant.                    
  653. X *           There is no static nesting of blocks or procedures,             
  654. X *           therefore all variables are either global or local.             
  655. X *                                                                           
  656. X *  The combination of these three aspects is balanced only approximately.   
  657. X *                                                                           
  658. X *  1. Statement Type:                                                       
  659. X *  -----------------             number
  660. X *                                                                           
  661. X *     V1 := V2                   15                                         
  662. X *     V := Constant              12                                         
  663. X *       (incl. V1 := F(..)                                                  
  664. X *     Assignment,                 7                                         
  665. X *       with array element                                                  
  666. X *     Assignment,                 6                                         
  667. X *       with record component                                               
  668. X *                                --                                       
  669. X *                                40       40                                
  670. X *                                                                           
  671. X *     X := Y +|-|and|or Z         5                                         
  672. X *     X := Y +|-|"=" Constant     6                                         
  673. X *     X := X +|- 1                3                                         
  674. X *     X := Y *|/ Z                2                                         
  675. X *     X := Expression,            1                                         
  676. X *          two operators                                                    
  677. X *     X := Expression,            1                                         
  678. X *          three operators                                                  
  679. X *                                --                                         
  680. X *                                18       18                                
  681. X *                                                                           
  682. X *     if .... then ....          14                                         
  683. X *       with "else"      7                                                  
  684. X *       without "else"   7                                                  
  685. X *           executed        3                                               
  686. X *           not executed    4                                               
  687. X *     for I in 1..N do ...        7  |  counted every time                  
  688. X *     while ... do ...            4  |  the loop condition                  
  689. X *     repeat ... until            1  |  is evaluated                        
  690. X *     case ... end                1                                         
  691. X *     with                        1                                         
  692. X *                                --                                         
  693. X *                                28       28                                
  694. X *                                                                           
  695. X *     P (...)  procedure call    10                                         
  696. X *     X := F (...)                                                          
  697. X *             function  call      5                                         
  698. X *                                --                                         
  699. X *                                15       15                                
  700. X *                                        ---                              
  701. X *                                        101                                
  702. X *                                                                           
  703. X *    22 of the 58 assignments have a variable of a constrained              
  704. X *    (sub-)type as their destination. In general, discriminant checks       
  705. X *    will be necessary in these cases; however, the compiler may            
  706. X *    optimize out some of these checks.                                     
  707. X *                                                                           
  708. X *    The average number of parameters in procedure or function calls        
  709. X *    is 1.80 (not counting the function values as implicit parameters).     
  710. X *                                                                           
  711. X *                                                                           
  712. X *  2. Operators                                                             
  713. X *  ------------                                                             
  714. X *                          number    approximate                            
  715. X *                                    percentage                             
  716. X *                                                                           
  717. X *    Arithmetic             27          52.9                                
  718. X *                                                                           
  719. X *       +                     16          31.4                              
  720. X *       -                      7          13.7                              
  721. X *       *                      3           5.9                              
  722. X *       div                    1           2.0                              
  723. X *                                                                           
  724. X *    Comparison             20           39.2                               
  725. X *                                                                           
  726. X *       =                      9           17.6                             
  727. X *       <>                     4            7.8                             
  728. X *       >                      1            2.0                             
  729. X *       <                      3            5.9                             
  730. X *       >=                     1            2.0                             
  731. X *       <=                     2            3.9                             
  732. X *                                                                           
  733. X *    Logic                   4            7.8                               
  734. X *                                                                           
  735. X *       AND                    1            2.0                             
  736. X *       OR                     1            2.0                             
  737. X *       NOT                    2            3.9                             
  738. X *                                                                           
  739. X *                           --          -----                               
  740. X *                           51           99.9                               
  741. X *                                                                           
  742. X *                                                                           
  743. X *  3. Operand Type (counted once per operand reference):                    
  744. X *  ---------------                                                          
  745. X *                          number    approximate                            
  746. X *                                    percentage                             
  747. X *                                                                           
  748. X *     Integer               135        54.7 %                               
  749. X *     Character              47        19.0 %                               
  750. X *     Enumeration            31        12.6 %                               
  751. X *     Boolean                13         5.3 %                               
  752. X *     Pointer                11         4.5 %                               
  753. X *     String30                6         2.4 %                               
  754. X *     Array                   2         0.8 %                               
  755. X *     Record                  2         0.8 %                               
  756. X *                           ---       -------                               
  757. X *                           247        100.1 %
  758. X *                                                                           
  759. X *  When there is an access path leading to the final operand (e.g. a record 
  760. X *  component), only the final data type on the access path is counted.      
  761. X *                                                                           
  762. X *  There are 16 accesses to components of a record, 9 of them go to         
  763. X *  a component in a variant part. For some of these accesses, the           
  764. X *  compiler may suppress generation of code checking the tag field          
  765. X *  during optimization.                                                     
  766. X *                                                                           
  767. X *                                                                           
  768. X *  3. Operand Locality:                                                     
  769. X *  -------------------                                                      
  770. X *                                                                           
  771. X *     local variable               84        34.0 %                         
  772. X *     global variable              58        23.5 %                         
  773. X *     parameter                    45        18.2 %                         
  774. X *        value                        23         9.3 %                      
  775. X *        reference                    22         8.9 %                      
  776. X *     function result               5         2.0 %                         
  777. X *     constant                     55        22.3 %                         
  778. X *                                 ---       -------                         
  779. X *                                 247       100.0 %                         
  780. X *                                                                           
  781. X *                                                                           
  782. X *  The program does not compute anything meaningful, but it is syntactically
  783. X *  and semantically correct. All variables have a value assigned to them    
  784. X *  before they are used as a source operand.                                
  785. X *                                                                           
  786. X *  There may be cases where a highly optimizing compiler may recognize      
  787. X *  unnecessary statements and may not generate code for them.               
  788. X *                                                                           
  789. X *  There has been no explicit effort to account for the effects of a        
  790. X *  cache, or to balance the use of long or short displacements for code or  
  791. X *  data.                                                                    
  792. X *                                                                           
  793. X ****************************************************************************
  794. X *)
  795. X
  796. Xprogram Dhrystone (input, output);
  797. X(***************)
  798. X
  799. Xconst (* for measurement *)
  800. X
  801. X  MicrosecondsPerClock  = 1000;
  802. X  ClocksPerSecond       = 1000;
  803. X        (* In Berkeley UNIX Pascal, the function "clock"        *)
  804. X        (* returns milliseconds                                 *)
  805. X  TooSmallTime          = 2000;
  806. X        (* Measurements should last at least 2 seconds          *)
  807. X
  808. Xtype
  809. X
  810. X  (* Global type definitions *)
  811. X
  812. X  Enumeration           = (Ident1, Ident2, Ident3, Ident4, Ident5);
  813. X
  814. X  OneToThirty           = 1..30;
  815. X  OneToFifty            = 1..50;
  816. X  CapitalLetter         = 'A'..'Z';
  817. X
  818. X  String30              = packed array [OneToThirty] of char;
  819. X
  820. X  Array1DimInteger      = array [OneToFifty] of integer;
  821. X  Array2DimInteger      = array [OneToFifty, OneToFifty] of integer;
  822. X
  823. X  RecordPointer         = ^RecordType;
  824. X
  825. X  RecordType            =
  826. X      record
  827. X        PointerComp:   RecordPointer;
  828. X        case Discr:    Enumeration of
  829. X          Ident1:         (* only this variant is used,           *)
  830. X                          (* but in some cases discriminant       *)
  831. X                          (* checks are necessary                 *)
  832. X            (EnumComp:      Enumeration;
  833. X             IntComp:       OneToFifty;
  834. X             StringComp:    String30);
  835. X          Ident2:
  836. X            (Enum2Comp:    Enumeration;
  837. X             String2Comp:  String30);
  838. X          Ident3, Ident4, Ident5:
  839. X            (Char1Comp,
  840. X             Char2Comp:    char);
  841. X      end; (* record *)
  842. X
  843. Xvar
  844. X
  845. X  (* Ada version: Variables local in Proc_0 *)
  846. X
  847. X  Int1Glob,
  848. X  Int2Glob,
  849. X  Int3Glob:       OneToFifty;
  850. X  CharIndex:      char;
  851. X  EnumGlob:       Enumeration;
  852. X  String1Glob,
  853. X  String2Glob:    String30;
  854. X
  855. X  (* Ada version: Variables global in Pack_1 *)
  856. X
  857. X  PointerGlob,
  858. X  NextPointerGlob: RecordPointer;
  859. X  IntGlob:         integer;
  860. X
  861. X  BoolGlob:        boolean;
  862. X  Char1Glob,
  863. X  Char2Glob:       char;
  864. X  Array1Glob:      Array1DimInteger;
  865. X  Array2Glob:      Array2DimInteger;
  866. X
  867. X  (* Variables for measurement *)
  868. X
  869. X  RunIndex,
  870. X  NumberOfRuns,
  871. X  BeginClock,
  872. X  EndClock,
  873. X  SumClocks:            integer;
  874. X  Microseconds,         
  875. X  DhrystonesPerSecond:  real;
  876. X  I:                    integer;
  877. X
  878. X  (* end of variables for measurement *)
  879. X
  880. Xprocedure Proc1 (    PointerParVal: RecordPointer);     forward;
  881. X
  882. Xprocedure Proc2 (var IntParRef:     OneToFifty);        forward;
  883. X
  884. Xprocedure Proc3 (var PointerParRef: RecordPointer);     forward;
  885. X
  886. Xprocedure Proc4;                                        forward;
  887. X  (* without parameters *)
  888. X
  889. Xprocedure Proc5;                                        forward;
  890. X  (* without parameters *)
  891. X
  892. Xprocedure Proc6 (    EnumParVal:    Enumeration;
  893. X                 var EnumParRef:    Enumeration);       forward;
  894. X
  895. Xprocedure Proc7 (    Int1ParVal,
  896. X                     Int2ParVal:    OneToFifty;
  897. X                 var IntParRef:     OneToFifty);        forward;
  898. X
  899. Xprocedure Proc8 (var Array1ParRef:  Array1DimInteger;
  900. X                 var Array2ParRef:  Array2DimInteger;
  901. X                     Int1ParVal,
  902. X                     Int2ParVal:    integer);            forward;
  903. X
  904. Xfunction Func1  (    Char1ParVal,
  905. X                     Char2ParVal:   CapitalLetter): 
  906. X                                            Enumeration; forward;
  907. X
  908. Xfunction Func2  (var String1ParRef,
  909. X                     String2ParRef: String30): 
  910. X                                            boolean;      forward;
  911. X
  912. Xfunction Func3  (    EnumParVal:    Enumeration): 
  913. X                                            boolean;      forward;
  914. X
  915. X
  916. Xprocedure Proc1; (* (PointerParVal: RecordPointer) *)
  917. X    (* executed once *)
  918. Xbegin
  919. X  with PointerParVal^.PointerComp^ (* = PointerGlobNext *) do
  920. X  begin
  921. X    PointerParVal^.PointerComp^ := PointerGlob^;
  922. X    PointerParVal^.IntComp := 5;
  923. X    IntComp := PointerParVal^.IntComp;
  924. X    PointerComp := PointerParVal^.PointerComp;
  925. X    Proc3 (PointerComp);
  926. X      (* PointerParVal^.PointerComp^.PointerComp = PointerGlob^.PointerComp *)
  927. X    if Discr = Ident1
  928. X    then (* executed *)
  929. X    begin
  930. X      IntComp := 6;
  931. X      Proc6 (PointerParVal^.EnumComp, EnumComp);
  932. X      PointerComp := PointerGlob^.PointerComp;
  933. X      Proc7 (IntComp, 10, IntComp);
  934. X    end (* then *)
  935. X    else (* not executed *)
  936. X      PointerParVal^ := PointerParVal^.PointerComp^;
  937. X  end; (* with *)
  938. Xend; (* Proc1 *)
  939. X
  940. X
  941. Xprocedure Proc2; (* (var IntParRef: OneToFifty) *)
  942. X    (* executed once *)
  943. X    (* InParRef = 3, becomes 7 *)
  944. Xvar
  945. X  IntLoc:  OneToFifty;
  946. X  EnumLoc: Enumeration;
  947. Xbegin
  948. X  IntLoc := IntParRef + 10;
  949. X  repeat (* executed once *)
  950. X    if Char1Glob = 'A'
  951. X    then (* executed *)
  952. X    begin
  953. X      IntLoc := IntLoc - 1;
  954. X      IntParRef := IntLoc - IntGlob;
  955. X      EnumLoc := Ident1;
  956. X    end (* if *)
  957. X  until EnumLoc = Ident1; (* true *)
  958. Xend; (* Proc2 *)
  959. X
  960. X
  961. Xprocedure Proc3; (* (var PointerParRef: RecordPointer) *)
  962. X    (* executed once *)
  963. X    (* PointerParRef becomes PointerGlob *)
  964. Xbegin
  965. X  if PointerGlob <> nil
  966. X  then (* executed *)
  967. X    PointerParRef := PointerGlob^.PointerComp;
  968. X  Proc7 (10, IntGlob, PointerGlob^.IntComp);
  969. Xend; (* Proc3 *)
  970. X
  971. X
  972. Xprocedure Proc4; (* without parameters *)
  973. X    (* executed once *)
  974. Xvar
  975. X  BoolLoc: boolean;
  976. Xbegin
  977. X  BoolLoc := Char1Glob = 'A';
  978. X  BoolGlob := BoolLoc or BoolGlob;
  979. X  Char2Glob := 'B';
  980. Xend; (* Proc4 *)
  981. X
  982. X
  983. Xprocedure Proc5; (* without parameters *)
  984. X    (* executed once *)
  985. Xbegin
  986. X  Char1Glob := 'A';
  987. X  BoolGlob := false;
  988. Xend; (* Proc5 *)
  989. X
  990. X
  991. Xprocedure Proc6; (* (    EnumParVal:     Enumeration;
  992. X                     var EnumParRef:     Enumeration) *)
  993. X    (* executed once *)
  994. X    (* EnumParVal = Ident3, EnumParRef becomes Ident2 *)
  995. Xbegin
  996. X  EnumParRef := EnumParVal;
  997. X  if not Func3 (EnumParVal)
  998. X  then (* not executed *)
  999. X    EnumParRef := Ident4;
  1000. X  case EnumParVal of
  1001. X    Ident1: EnumParRef := Ident1;
  1002. X    Ident2: if IntGlob > 100
  1003. X              then EnumParRef := Ident1
  1004. X              else EnumParRef := Ident4;
  1005. X    Ident3: EnumParRef := Ident2;    (* executed *)
  1006. X    Ident4: ;
  1007. X    Ident5: EnumParRef := Ident3;
  1008. X  end; (* case *)
  1009. Xend; (* Proc6 *)
  1010. X
  1011. X
  1012. Xprocedure Proc7; (* (    Int1ParVal,
  1013. X                         Int2ParVal:    OneToFifty;
  1014. X                     var IntParRef:     OneToFifty) *)
  1015. X    (* executed three times                               *)
  1016. X    (* first call:      Int1ParVal = 2, Int2ParVal = 3,   *)
  1017. X    (*                  IntParRef becomes 7               *)
  1018. X    (* second call:     Int1ParVal = 10, Int2ParVal = 5,  *)
  1019. X    (*                  IntParRef becomes 17              *)
  1020. X    (* third call:      Int1ParVal = 6, Int2ParVal = 10,  *)
  1021. X    (*                  IntParRef becomes 18              *)
  1022. Xvar
  1023. X  IntLoc: OneToFifty;
  1024. Xbegin
  1025. X  IntLoc := Int1ParVal + 2;
  1026. X  IntParRef := Int2ParVal + IntLoc;
  1027. Xend; (* Proc7 *)
  1028. X
  1029. X
  1030. Xprocedure Proc8; (* (var Array1ParRef: Array1DimInteger;
  1031. X                     var Array2ParRef: Array2DimInteger;
  1032. X                         Int1ParVal,
  1033. X                         Int2ParVal:    integer)          *)
  1034. X    (* executed once  *)
  1035. X    (* Int1ParVal = 3 *)
  1036. X    (* Int2ParVal = 7 *)
  1037. Xvar
  1038. X  IntIndex,
  1039. X  IntLoc:   OneToFifty;
  1040. Xbegin
  1041. X  IntLoc := Int1ParVal + 5;
  1042. X  Array1ParRef [IntLoc] := Int2ParVal;
  1043. X  Array1ParRef [IntLoc+1] := Array1ParRef [IntLoc];
  1044. X  Array1ParRef [IntLoc+30] := IntLoc;
  1045. X  for IntIndex := IntLoc to IntLoc+1 do
  1046. X    Array2ParRef [IntLoc, IntIndex] := IntLoc;
  1047. X  Array2ParRef [IntLoc, IntLoc-1] := Array2ParRef [IntLoc, IntLoc-1] + 1;
  1048. X  Array2ParRef [IntLoc+20, IntLoc] := Array1ParRef [IntLoc];
  1049. X  IntGlob := 5;
  1050. Xend; (* Proc8 *)
  1051. X
  1052. X
  1053. Xfunction Func1; (* (Char1ParVal,
  1054. X                    Char2ParVal: CapitalLetter): Enumeration *)
  1055. X    (* executed three times, returns always Ident1              *)
  1056. X    (* first call:      Char1ParVal = 'H', Char2ParVal = 'R'    *)
  1057. X    (* second call:     Char1ParVal = 'A', Char2ParVal = 'C'    *)
  1058. X    (* third call:      Char1ParVal = 'B', Char2ParVal = 'C'    *)
  1059. Xvar
  1060. X  Char1Loc, Char2Loc: CapitalLetter;
  1061. Xbegin
  1062. X  Char1Loc := Char1ParVal;
  1063. X  Char2Loc := Char1Loc;
  1064. X  if Char2Loc <> Char2ParVal
  1065. X  then  (* executed *)
  1066. X    Func1 := Ident1
  1067. X  else  (* not executed *)
  1068. X  begin
  1069. X    Char1Glob := Char1Loc;
  1070. X    Func1 := Ident2;
  1071. X  end;
  1072. Xend; (* Func1 *)
  1073. X
  1074. X
  1075. Xfunction Func2; (* (var String1ParRef,
  1076. X                        String2ParRef: String30): boolean *)
  1077. X    (* executed once, returns false              *)
  1078. X    (* String1ParRef = 'DHRYSTONE PROGRAM, 1''ST STRING' *)
  1079. X    (* String2ParRef = 'DHRYSTONE PROGRAM, 2''ND STRING' *)
  1080. Xvar
  1081. X  IntLoc:  OneToThirty;
  1082. X  CharLoc: CapitalLetter;
  1083. Xbegin
  1084. X  IntLoc := 2;
  1085. X  while IntLoc <= 2 do (* loop body executed once *)
  1086. X    if Func1 (String1ParRef[IntLoc],
  1087. X              String2ParRef[IntLoc+1]) = Ident1
  1088. X    then (* executed *)
  1089. X    begin
  1090. X      CharLoc := 'A';
  1091. X      IntLoc := IntLoc + 1;
  1092. X    end; (* if, while *)
  1093. X  if (CharLoc >= 'W') and (CharLoc < 'Z')
  1094. X  then (* not executed *)
  1095. X    IntLoc := 7;
  1096. X  if CharLoc = 'R'
  1097. X  then (* not executed *)
  1098. X    Func2 := true
  1099. X  else (* executed *)
  1100. X  begin
  1101. X    if String1ParRef > String2ParRef
  1102. X    then (* not executed *)
  1103. X    begin
  1104. X      IntLoc := IntLoc + 7;
  1105. X      IntGlob := IntLoc;
  1106. X      Func2 := true
  1107. X    end
  1108. X    else (* executed *)
  1109. X      Func2 := false;
  1110. X  end; (* if CharLoc *)
  1111. Xend; (* Func2 *)
  1112. X
  1113. X
  1114. Xfunction Func3; (* (EnumParVal: Enumeration): boolean *)
  1115. X    (* executed once, returns true      *)
  1116. X    (* EnumParVal = Ident3              *)
  1117. Xvar
  1118. X  EnumLoc:  Enumeration;
  1119. Xbegin
  1120. X  EnumLoc := EnumParVal;
  1121. X  if EnumLoc = Ident3
  1122. X  then (* executed *)
  1123. X    Func3 := true
  1124. X  else (* not executed *)
  1125. X    Func3 := false;
  1126. Xend; (* Func3 *)
  1127. X
  1128. X
  1129. Xbegin (* main program, corresponds to procedures        *)
  1130. X      (* Main and Proc_0 in the Ada version             *)
  1131. X
  1132. X  (* Initializations *)
  1133. X
  1134. X  new (NextPointerGlob);
  1135. X
  1136. X  new (PointerGlob);
  1137. X
  1138. X  PointerGlob^.PointerComp := NextPointerGlob;
  1139. X  PointerGlob^.Discr       := Ident1;
  1140. X  PointerGlob^.EnumComp    := Ident3;
  1141. X  PointerGlob^.IntComp     := 40;
  1142. X  PointerGlob^.StringComp  := 'DHRYSTONE PROGRAM, SOME STRING';
  1143. X
  1144. X  String1Glob := 'DHRYSTONE PROGRAM, 1''ST STRING';
  1145. X
  1146. X  Array2Glob [8,7] := 10;
  1147. X
  1148. X  writeln;
  1149. X  writeln ('Dhrystone Benchmark, Version 2.1 (Language: Pascal)');
  1150. X  writeln;
  1151. X  writeln ('Please give the number of runs through the benchmark: ');
  1152. X  readln (NumberOfRuns);
  1153. X  writeln;
  1154. X  writeln ('Execution starts, ', NumberOfRuns : 7, ' runs through Dhrystone');
  1155. X
  1156. X  BeginClock := clock;
  1157. X
  1158. X  (***************)
  1159. X  (* Start timer *)
  1160. X  (***************)
  1161. X  
  1162. X  for RunIndex := 1 to NumberOfRuns do
  1163. X  begin
  1164. X
  1165. X    Proc5;
  1166. X    Proc4;
  1167. X      (* Char1Glob = 'A', Char2Glob = 'B', BoolGlob = false *)
  1168. X    Int1Glob := 2;
  1169. X    Int2Glob := 3;
  1170. X    String2Glob := 'DHRYSTONE PROGRAM, 2''ND STRING';
  1171. X    EnumGlob := Ident2;
  1172. X    BoolGlob := not Func2 (String1Glob, String2Glob);
  1173. X      (* BoolGlob = true *)
  1174. X    while Int1Glob < Int2Glob do  (* loop body executed once *)
  1175. X    begin
  1176. X      Int3Glob := 5 * Int1Glob - Int2Glob;
  1177. X        (* Int3Glob = 7 *)
  1178. X      Proc7 (Int1Glob, Int2Glob, Int3Glob);
  1179. X        (* Int3Glob = 7 *)
  1180. X      Int1Glob := Int1Glob + 1;
  1181. X    end; (* while *)
  1182. X      (* Int1Glob = 3 *)
  1183. X    Proc8 (Array1Glob, Array2Glob, Int1Glob, Int3Glob);
  1184. X      (* IntGlob = 5 *)
  1185. X    Proc1 (PointerGlob);
  1186. X    for CharIndex := 'A' to Char2Glob do   (* loop body executed twice *)
  1187. X      if EnumGlob = Func1 (CharIndex, 'C')
  1188. X        then (* not executed *)
  1189. X        begin
  1190. X          Proc6 (Ident1, EnumGlob);
  1191. X          String2Glob := 'DHRYSTONE PROGRAM, 3''RD STRING';
  1192. X          Int2Glob := RunIndex;
  1193. X          IntGlob := RunIndex;
  1194. X        end;
  1195. X    (* Int1Glob = 3, Int2Glob = 3, Int3Glob = 7 *)
  1196. X    Int2Glob := Int2Glob * Int1Glob;
  1197. X    Int1Glob := Int2Glob div Int3Glob;
  1198. X    Int2Glob := 7 * (Int2Glob - Int3Glob) - Int1Glob;
  1199. X      (* Int1Glob = 1, Int2Glob = 13, Int3Glob = 7 *)
  1200. X    Proc2 (Int1Glob);
  1201. X      (* Int1Glob = 5 *)
  1202. X
  1203. X  end; (* for RunIndex *)
  1204. X
  1205. X  EndClock := clock;
  1206. X
  1207. X  (**************)
  1208. X  (* Stop timer *)
  1209. X  (**************)
  1210. X
  1211. X  writeln ('Execution ends');
  1212. X  writeln;
  1213. X  writeln ('Final values of the variables used in the benchmark:');
  1214. X  writeln;
  1215. X
  1216. X  writeln ('IntGlob:                      ', IntGlob : 5);
  1217. X  writeln ('        should be:                5');
  1218. X  write ('BoolGlob:                      ');
  1219. X  if BoolGlob = true
  1220. X  then
  1221. X    writeln ('TRUE')
  1222. X  else
  1223. X    writeln ('FALSE');
  1224. X  writeln ('        should be:             TRUE');
  1225. X  writeln ('Char1Glob:                        ', Char1Glob);
  1226. X  writeln ('        should be:                A');
  1227. X  writeln ('Char2Glob:                        ', Char2Glob);
  1228. X  writeln ('        should be:                B');
  1229. X  writeln ('Array1Glob [8]:               ', Array1Glob [8] : 5);
  1230. X  writeln ('        should be:                7');
  1231. X  writeln ('Array2Glob [8,7]:             ', Array2Glob [8,7] : 5);
  1232. X  writeln ('        should be:                NumberOfRuns + 10');
  1233. X  writeln ('PointerGlob^.Discr:           ', ord (PointerGlob^.Discr) : 5);
  1234. X  writeln ('        should be:                0');
  1235. X  writeln ('PointerGlob^.EnumComp:        ', ord (PointerGlob^.EnumComp) : 5);
  1236. X  writeln ('        should be:                2');
  1237. X  writeln ('PointerGlob^.IntComp  :       ', PointerGlob^.IntComp : 5);
  1238. X  writeln ('        should be:               17');
  1239. X  write   ('PointerGlob^.StringComp:     ');
  1240. X  for I := 1 to 30 do
  1241. X    write (PointerGlob^.StringComp [I]);
  1242. X  writeln;
  1243. X  writeln ('        should be:           DHRYSTONE PROGRAM, SOME STRING');
  1244. X  writeln ('NextPointerGlob^.Discr:       ', ord (NextPointerGlob^.Discr) : 5);
  1245. X  writeln ('        should be:                0');
  1246. X  writeln ('NextPointerGlob^.EnumComp:    ',
  1247. X                    ord (NextPointerGlob^.EnumComp) : 5);
  1248. X  writeln ('        should be:                1');
  1249. X  writeln ('NextPointerGlob^.IntComp:     ', NextPointerGlob^.IntComp : 5);
  1250. X  writeln ('        should be:               18');
  1251. X  write   ('NextPointerGlob^.StringComp: ');
  1252. X  for I := 1 to 30 do
  1253. X    write (NextPointerGlob^.StringComp [I]);
  1254. X  writeln;
  1255. X  writeln ('        should be:           DHRYSTONE PROGRAM, SOME STRING');
  1256. X  writeln ('Int1Glob:                     ', Int1Glob : 5);
  1257. X  writeln ('        should be:                5');
  1258. X  writeln ('Int2Glob:                     ', Int2Glob : 5);
  1259. X  writeln ('        should be:               13');
  1260. X  writeln ('Int3Glob:                     ', Int3Glob : 5);
  1261. X  writeln ('        should be:                7');
  1262. X  writeln ('EnumGlob:                     ', ord (EnumGlob) : 5);
  1263. X  writeln ('        should be:                1');
  1264. X  write   ('String1Glob:                 ');
  1265. X  for I := 1 to 30 do
  1266. X    write (String1Glob [I]);
  1267. X  writeln;
  1268. X  writeln ('        should be:           DHRYSTONE PROGRAM, 1''ST STRING');
  1269. X  write   ('String2Glob:                 ');
  1270. X  for I := 1 to 30 do
  1271. X    write (String2Glob [I]);
  1272. X  writeln;
  1273. X  writeln ('        should be:           DHRYSTONE PROGRAM, 2''ND STRING');
  1274. X  writeln;
  1275. X  writeln;
  1276. X
  1277. X  SumClocks := EndClock - BeginClock;
  1278. X
  1279. X  if SumClocks < TooSmallTime
  1280. X    then
  1281. X    begin
  1282. X      writeln ('Measured time too small to obtain meaningful results');
  1283. X      writeln ('Please increase number of runs');
  1284. X      writeln;
  1285. X    end
  1286. X    else
  1287. X    begin
  1288. X      Microseconds := SumClocks * (MicrosecondsPerClock / NumberOfRuns);
  1289. X                                (* Brackets to prevent integer overflow *)
  1290. X      DhrystonesPerSecond := NumberOfRuns * (ClocksPerSecond / SumClocks);
  1291. X      write ('Microseconds for one run through Dhrystone: ');
  1292. X      writeln (Microseconds : 8 : 1);
  1293. X      write ('Dhrystones per Second:                      ');
  1294. X      writeln (DhrystonesPerSecond : 8 : 1);
  1295. X      writeln;
  1296. X    end;
  1297. X  
  1298. Xend.
  1299. SHAR_EOF
  1300. if test 37108 -ne "`wc -c < 'dhry.p'`"
  1301. then
  1302.     echo shar: "error transmitting 'dhry.p'" '(should have been 37108 characters)'
  1303. fi
  1304. fi
  1305. exit 0
  1306. #    End of shell archive
  1307.  
  1308.  
  1309.