home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / byte-benchmarks3.1 / part04 < prev    next >
Encoding:
Text File  |  1992-02-01  |  20.5 KB  |  485 lines

  1. Newsgroups: comp.sources.unix
  2. From: ben@bytepb.byte.com (Ben Smith @ BYTE)
  3. Subject: v25i111: BYTE Benchmarks, V3.1, Part04/04
  4. Sender: sources-moderator@pa.dec.com
  5. Approved: vixie@pa.dec.com
  6.  
  7. Submitted-By: ben@bytepb.byte.com (Ben Smith @ BYTE)
  8. Posting-Number: Volume 25, Issue 111
  9. Archive-Name: byte-benchmarks3.1/part04
  10.  
  11. #! /bin/sh
  12. # This is a shell archive.  Remove anything before this line, then unpack
  13. # it by saving it into a file and typing "sh file".  To overwrite existing
  14. # files, type "sh file -c".  You can also feed this as standard input via
  15. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  16. # will see the following message at the end:
  17. #        "End of archive 4 (of 4)."
  18. # Contents:  src/dhry.h
  19. # Wrapped by vixie@cognition.pa.dec.com on Sun Feb  2 16:27:41 1992
  20. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  21. if test -f 'src/dhry.h' -a "${1}" != "-c" ; then 
  22.   echo shar: Will not clobber existing file \"'src/dhry.h'\"
  23. else
  24. echo shar: Extracting \"'src/dhry.h'\" \(18918 characters\)
  25. sed "s/^X//" >'src/dhry.h' <<'END_OF_FILE'
  26. X/*****************************************************************************
  27. X *  The BYTE UNIX Benchmarks - Release 3
  28. X *          Module: dhry.h   SID: 3.4 5/15/91 19:30:21
  29. X *          
  30. X *****************************************************************************
  31. X * Bug reports, patches, comments, suggestions should be sent to:
  32. X *
  33. X *    Ben Smith, Rick Grehan or Tom Yager
  34. X *    ben@bytepb.byte.com   rick_g@bytepb.byte.com   tyager@bytepb.byte.com
  35. X *
  36. X *****************************************************************************
  37. X *  Modification Log:
  38. X *  addapted from:
  39. X *
  40. X *
  41. X *                   "DHRYSTONE" Benchmark Program
  42. X *                   -----------------------------
  43. X *                                                                            
  44. X *  Version:    C, Version 2.1
  45. X *                                                                            
  46. X *  File:       dhry.h (part 1 of 3)
  47. X *
  48. X *  Date:       May 25, 1988
  49. X *
  50. X *  Author:     Reinhold P. Weicker
  51. X *                      Siemens AG, AUT E 51
  52. X *                      Postfach 3220
  53. X *                      8520 Erlangen
  54. X *                      Germany (West)
  55. X *                              Phone:  [+49]-9131-7-20330
  56. X *                                      (8-17 Central European Time)
  57. X *                              Usenet: ..!mcvax!unido!estevax!weicker
  58. X *
  59. X *              Original Version (in Ada) published in
  60. X *              "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
  61. X *              pp. 1013 - 1030, together with the statistics
  62. X *              on which the distribution of statements etc. is based.
  63. X *
  64. X *              In this C version, the following C library functions are used:
  65. X *              - strcpy, strcmp (inside the measurement loop)
  66. X *              - printf, scanf (outside the measurement loop)
  67. X *              In addition, Berkeley UNIX system calls "times ()" or "time ()"
  68. X *              are used for execution time measurement. For measurements
  69. X *              on other systems, these calls have to be changed.
  70. X *
  71. X *  Collection of Results:
  72. X *              Reinhold Weicker (address see above) and
  73. X *              
  74. X *              Rick Richardson
  75. X *              PC Research. Inc.
  76. X *              94 Apple Orchard Drive
  77. X *              Tinton Falls, NJ 07724
  78. X *                      Phone:  (201) 834-1378 (9-17 EST)               
  79. X *                      Usenet: ...!seismo!uunet!pcrat!rick
  80. X *
  81. X *      Please send results to Rick Richardson and/or Reinhold Weicker.
  82. X *      Complete information should be given on hardware and software used.
  83. X *      Hardware information includes: Machine type, CPU, type and size
  84. X *      of caches; for microprocessors: clock frequency, memory speed
  85. X *      (number of wait states).
  86. X *      Software information includes: Compiler (and runtime library)
  87. X *      manufacturer and version, compilation switches, OS version.
  88. X *      The Operating System version may give an indication about the
  89. X *      compiler; Dhrystone itself performs no OS calls in the measurement loop.
  90. X *
  91. X *      The complete output generated by the program should be mailed
  92. X *      such that at least some checks for correctness can be made.
  93. X *
  94. X ***************************************************************************
  95. X *
  96. X *  History:    This version C/2.1 has been made for two reasons:
  97. X *
  98. X *              1) There is an obvious need for a common C version of
  99. X *              Dhrystone, since C is at present the most popular system
  100. X *              programming language for the class of processors
  101. X *              (microcomputers, minicomputers) where Dhrystone is used most.
  102. X *              There should be, as far as possible, only one C version of
  103. X *              Dhrystone such that results can be compared without
  104. X *              restrictions. In the past, the C versions distributed
  105. X *              by Rick Richardson (Version 1.1) and by Reinhold Weicker
  106. X *              had small (though not significant) differences.
  107. X *
  108. X *              2) As far as it is possible without changes to the Dhrystone
  109. X *              statistics, optimizing compilers should be prevented from
  110. X *              removing significant statements.
  111. X *
  112. X *              This C version has been developed in cooperation with
  113. X *              Rick Richardson (Tinton Falls, NJ), it incorporates many
  114. X *              ideas from the "Version 1.1" distributed previously by
  115. X *              him over the UNIX network Usenet.
  116. X *              I also thank Chaim Benedelac (National Semiconductor),
  117. X *              David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
  118. X *              Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
  119. X *              for their help with comments on earlier versions of the
  120. X *              benchmark.
  121. X *
  122. X *  Changes:    In the initialization part, this version follows mostly
  123. X *              Rick Richardson's version distributed via Usenet, not the
  124. X *              version distributed earlier via floppy disk by Reinhold Weicker.
  125. X *              As a concession to older compilers, names have been made
  126. X *              unique within the first 8 characters.
  127. X *              Inside the measurement loop, this version follows the
  128. X *              version previously distributed by Reinhold Weicker.
  129. X *
  130. X *              At several places in the benchmark, code has been added,
  131. X *              but within the measurement loop only in branches that 
  132. X *              are not executed. The intention is that optimizing compilers
  133. X *              should be prevented from moving code out of the measurement
  134. X *              loop, or from removing code altogether. Since the statements
  135. X *              that are executed within the measurement loop have NOT been
  136. X *              changed, the numbers defining the "Dhrystone distribution"
  137. X *              (distribution of statements, operand types and locality)
  138. X *              still hold. Except for sophisticated optimizing compilers,
  139. X *              execution times for this version should be the same as
  140. X *              for previous versions.
  141. X *              
  142. X *              Since it has proven difficult to subtract the time for the
  143. X *              measurement loop overhead in a correct way, the loop check
  144. X *              has been made a part of the benchmark. This does have
  145. X *              an impact - though a very minor one - on the distribution
  146. X *              statistics which have been updated for this version.
  147. X *
  148. X *              All changes within the measurement loop are described
  149. X *              and discussed in the companion paper "Rationale for
  150. X *              Dhrystone version 2".
  151. X *
  152. X *              Because of the self-imposed limitation that the order and
  153. X *              distribution of the executed statements should not be
  154. X *              changed, there are still cases where optimizing compilers
  155. X *              may not generate code for some statements. To a certain
  156. X *              degree, this is unavoidable for small synthetic benchmarks.
  157. X *              Users of the benchmark are advised to check code listings
  158. X *              whether code is generated for all statements of Dhrystone.
  159. X *
  160. X *              Version 2.1 is identical to version 2.0 distributed via
  161. X *              the UNIX network Usenet in March 1988 except that it corrects
  162. X *              some minor deficiencies that were found by users of version 2.0.
  163. X *              The only change within the measurement loop is that a
  164. X *              non-executed "else" part was added to the "if" statement in
  165. X *              Func_3, and a non-executed "else" part removed from Proc_3.
  166. X *
  167. X ***************************************************************************
  168. X *
  169. X * Defines:     The following "Defines" are possible:
  170. X *              -DREG=register          (default: Not defined)
  171. X *                      As an approximation to what an average C programmer
  172. X *                      might do, the "register" storage class is applied
  173. X *                      (if enabled by -DREG=register)
  174. X *                      - for local variables, if they are used (dynamically)
  175. X *                        five or more times
  176. X *                      - for parameters if they are used (dynamically)
  177. X *                        six or more times
  178. X *                      Note that an optimal "register" strategy is
  179. X *                      compiler-dependent, and that "register" declarations
  180. X *                      do not necessarily lead to faster execution.
  181. X *              -DNOSTRUCTASSIGN        (default: Not defined)
  182. X *                      Define if the C compiler does not support
  183. X *                      assignment of structures.
  184. X *              -DNOENUMS               (default: Not defined)
  185. X *                      Define if the C compiler does not support
  186. X *                      enumeration types.
  187. X *              -DTIMES                 (default)
  188. X *              -DTIME
  189. X *                      The "times" function of UNIX (returning process times)
  190. X *                      or the "time" function (returning wallclock time)
  191. X *                      is used for measurement. 
  192. X *                      For single user machines, "time ()" is adequate. For
  193. X *                      multi-user machines where you cannot get single-user
  194. X *                      access, use the "times ()" function. If you have
  195. X *                      neither, use a stopwatch in the dead of night.
  196. X *                      "printf"s are provided marking the points "Start Timer"
  197. X *                      and "Stop Timer". DO NOT use the UNIX "time(1)"
  198. X *                      command, as this will measure the total time to
  199. X *                      run this program, which will (erroneously) include
  200. X *                      the time to allocate storage (malloc) and to perform
  201. X *                      the initialization.
  202. X *              -DHZ=nnn
  203. X *                      In Berkeley UNIX, the function "times" returns process
  204. X *                      time in 1/HZ seconds, with HZ = 60 for most systems.
  205. X *                      CHECK YOUR SYSTEM DESCRIPTION BEFORE YOU JUST APPLY
  206. X *                      A VALUE.
  207. X *
  208. X ***************************************************************************
  209. X *
  210. X *  Compilation model and measurement (IMPORTANT):
  211. X *
  212. X *  This C version of Dhrystone consists of three files:
  213. X *  - dhry.h (this file, containing global definitions and comments)
  214. X *  - dhry_1.c (containing the code corresponding to Ada package Pack_1)
  215. X *  - dhry_2.c (containing the code corresponding to Ada package Pack_2)
  216. X *
  217. X *  The following "ground rules" apply for measurements:
  218. X *  - Separate compilation
  219. X *  - No procedure merging
  220. X *  - Otherwise, compiler optimizations are allowed but should be indicated
  221. X *  - Default results are those without register declarations
  222. X *  See the companion paper "Rationale for Dhrystone Version 2" for a more
  223. X *  detailed discussion of these ground rules.
  224. X *
  225. X *  For 16-Bit processors (e.g. 80186, 80286), times for all compilation
  226. X *  models ("small", "medium", "large" etc.) should be given if possible,
  227. X *  together with a definition of these models for the compiler system used.
  228. X *
  229. X **************************************************************************
  230. X *
  231. X *  Dhrystone (C version) statistics:
  232. X *
  233. X *  [Comment from the first distribution, updated for version 2.
  234. X *   Note that because of language differences, the numbers are slightly
  235. X *   different from the Ada version.]
  236. X *
  237. X *  The following program contains statements of a high level programming
  238. X *  language (here: C) in a distribution considered representative:           
  239. X *
  240. X *    assignments                  52 (51.0 %)
  241. X *    control statements           33 (32.4 %)
  242. X *    procedure, function calls    17 (16.7 %)
  243. X *
  244. X *  103 statements are dynamically executed. The program is balanced with
  245. X *  respect to the three aspects:                                             
  246. X *
  247. X *    - statement type
  248. X *    - operand type
  249. X *    - operand locality
  250. X *         operand global, local, parameter, or constant.                     
  251. X *
  252. X *  The combination of these three aspects is balanced only approximately.    
  253. X *
  254. X *  1. Statement Type:                                                        
  255. X *  -----------------             number
  256. X *
  257. X *     V1 = V2                     9
  258. X *       (incl. V1 = F(..)
  259. X *     V = Constant               12
  260. X *     Assignment,                 7
  261. X *       with array element
  262. X *     Assignment,                 6
  263. X *       with record component
  264. X *                                --
  265. X *                                34       34
  266. X *
  267. X *     X = Y +|-|"&&"|"|" Z        5
  268. X *     X = Y +|-|"==" Constant     6
  269. X *     X = X +|- 1                 3
  270. X *     X = Y *|/ Z                 2
  271. X *     X = Expression,             1
  272. X *           two operators
  273. X *     X = Expression,             1
  274. X *           three operators
  275. X *                                --
  276. X *                                18       18
  277. X *
  278. X *     if ....                    14
  279. X *       with "else"      7
  280. X *       without "else"   7
  281. X *           executed        3
  282. X *           not executed    4
  283. X *     for ...                     7  |  counted every time
  284. X *     while ...                   4  |  the loop condition
  285. X *     do ... while                1  |  is evaluated
  286. X *     switch ...                  1
  287. X *     break                       1
  288. X *     declaration with            1
  289. X *       initialization
  290. X *                                --
  291. X *                                34       34
  292. X *
  293. X *     P (...)  procedure call    11
  294. X *       user procedure      10
  295. X *       library procedure    1
  296. X *     X = F (...)
  297. X *             function  call      6
  298. X *       user function        5                                         
  299. X *       library function     1                                               
  300. X *                                --                                          
  301. X *                                17       17
  302. X *                                        ---
  303. X *                                        103
  304. X *
  305. X *    The average number of parameters in procedure or function calls
  306. X *    is 1.82 (not counting the function values as implicit parameters).
  307. X *
  308. X *
  309. X *  2. Operators
  310. X *  ------------
  311. X *                          number    approximate
  312. X *                                    percentage
  313. X *
  314. X *    Arithmetic             32          50.8                                 
  315. X *
  316. X *       +                     21          33.3                              
  317. X *       -                      7          11.1                              
  318. X *       *                      3           4.8
  319. X *       / (int div)            1           1.6
  320. X *
  321. X *    Comparison             27           42.8
  322. X *
  323. X *       ==                     9           14.3
  324. X *       /=                     4            6.3
  325. X *       >                      1            1.6
  326. X *       <                      3            4.8
  327. X *       >=                     1            1.6
  328. X *       <=                     9           14.3
  329. X *
  330. X *    Logic                   4            6.3
  331. X *
  332. X *       && (AND-THEN)          1            1.6
  333. X *       |  (OR)                1            1.6
  334. X *       !  (NOT)               2            3.2
  335. X * 
  336. X *                           --          -----
  337. X *                           63          100.1
  338. X *
  339. X *
  340. X *  3. Operand Type (counted once per operand reference):
  341. X *  ---------------
  342. X *                          number    approximate
  343. X *                                    percentage
  344. X *
  345. X *     Integer               175        72.3 %
  346. X *     Character              45        18.6 %
  347. X *     Pointer                12         5.0 %
  348. X *     String30                6         2.5 %
  349. X *     Array                   2         0.8 %
  350. X *     Record                  2         0.8 %
  351. X *                           ---       -------
  352. X *                           242       100.0 %
  353. X *
  354. X *  When there is an access path leading to the final operand (e.g. a record
  355. X *  component), only the final data type on the access path is counted.       
  356. X *
  357. X *
  358. X *  4. Operand Locality:                                                      
  359. X *  -------------------
  360. X *                                number    approximate
  361. X *                                          percentage
  362. X *
  363. X *     local variable              114        47.1 %
  364. X *     global variable              22         9.1 %
  365. X *     parameter                    45        18.6 %
  366. X *        value                        23         9.5 %
  367. X *        reference                    22         9.1 %
  368. X *     function result               6         2.5 %
  369. X *     constant                     55        22.7 %
  370. X *                                 ---       -------
  371. X *                                 242       100.0 %
  372. X *
  373. X *
  374. X *  The program does not compute anything meaningful, but it is syntactically
  375. X *  and semantically correct. All variables have a value assigned to them
  376. X *  before they are used as a source operand.
  377. X *
  378. X *  There has been no explicit effort to account for the effects of a
  379. X *  cache, or to balance the use of long or short displacements for code or
  380. X *  data.
  381. X *
  382. X ***************************************************************************
  383. X */
  384. X
  385. X
  386. X/* Compiler and system dependent definitions: */
  387. X
  388. X#ifndef TIME
  389. X#define TIMES
  390. X#endif
  391. X                /* Use times(2) time function unless    */
  392. X                /* explicitly defined otherwise         */
  393. X
  394. X#ifdef TIMES
  395. X#include <sys/types.h>
  396. X#include <sys/times.h>
  397. X                /* for "times" */
  398. X#endif
  399. X
  400. X#define Mic_secs_Per_Second     1000000.0
  401. X                /* Berkeley UNIX C returns process times in seconds/HZ */
  402. X
  403. X#ifdef  NOSTRUCTASSIGN
  404. X#define structassign(d, s)      memcpy(&(d), &(s), sizeof(d))
  405. X#else
  406. X#define structassign(d, s)      d = s
  407. X#endif
  408. X
  409. X#ifdef  NOENUM
  410. X#define Ident_1 0
  411. X#define Ident_2 1
  412. X#define Ident_3 2
  413. X#define Ident_4 3
  414. X#define Ident_5 4
  415. X  typedef int   Enumeration;
  416. X#else
  417. X  typedef       enum    {Ident_1, Ident_2, Ident_3, Ident_4, Ident_5}
  418. X                Enumeration;
  419. X#endif
  420. X        /* for boolean and enumeration types in Ada, Pascal */
  421. X
  422. X/* General definitions: */
  423. X
  424. X#include <stdio.h>
  425. X                /* for strcpy, strcmp */
  426. X
  427. X#define Null 0 
  428. X                /* Value of a Null pointer */
  429. X#define true  1
  430. X#define false 0
  431. X
  432. typedef int     One_Thirty;
  433. typedef int     One_Fifty;
  434. typedef char    Capital_Letter;
  435. typedef int     Boolean;
  436. typedef char    Str_30 [31];
  437. typedef int     Arr_1_Dim [50];
  438. typedef int     Arr_2_Dim [50] [50];
  439. X
  440. typedef struct record 
  441. X    {
  442. X    struct record *Ptr_Comp;
  443. X    Enumeration    Discr;
  444. X    union {
  445. X          struct {
  446. X                  Enumeration Enum_Comp;
  447. X                  int         Int_Comp;
  448. X                  char        Str_Comp [31];
  449. X                  } var_1;
  450. X          struct {
  451. X                  Enumeration E_Comp_2;
  452. X                  char        Str_2_Comp [31];
  453. X                  } var_2;
  454. X          struct {
  455. X                  char        Ch_1_Comp;
  456. X                  char        Ch_2_Comp;
  457. X                  } var_3;
  458. X          } variant;
  459. X      } Rec_Type, *Rec_Pointer;
  460. X
  461. END_OF_FILE
  462. if test 18918 -ne `wc -c <'src/dhry.h'`; then
  463.     echo shar: \"'src/dhry.h'\" unpacked with wrong size!
  464. fi
  465. chmod +x 'src/dhry.h'
  466. # end of 'src/dhry.h'
  467. fi
  468. echo shar: End of archive 4 \(of 4\).
  469. cp /dev/null ark4isdone
  470. MISSING=""
  471. for I in 1 2 3 4 ; do
  472.     if test ! -f ark${I}isdone ; then
  473.     MISSING="${MISSING} ${I}"
  474.     fi
  475. done
  476. if test "${MISSING}" = "" ; then
  477.     echo You have unpacked all 4 archives.
  478.     rm -f ark[1-9]isdone
  479. else
  480.     echo You still need to unpack the following archives:
  481.     echo "        " ${MISSING}
  482. fi
  483. ##  End of shell archive.
  484. exit 0
  485.