home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 161_01 / unix.d < prev    next >
Text File  |  1985-11-26  |  7KB  |  285 lines

  1. ###alltyp.sh
  2. set -x
  3.  
  4. cc -o groups groups.c libtim -lm
  5.  
  6. Makex dadd; groups <dadd.out >dadd.grp
  7. Makex dand; groups <dand.out >dand.grp
  8. Makex dban; groups <dban.out >dban.grp
  9. Makex dbor; groups <dbor.out >dbor.grp
  10. Makex ddiv; groups <ddiv.out >ddiv.grp
  11. Makex deor; groups <deor.out >deor.grp
  12. Makex deq; groups <deq.out >deq.grp
  13. Makex dlsh; groups <dlsh.out >dlsh.grp
  14. Makex dlt; groups <dlt.out >dlt.grp
  15. Makex dmul; groups <dmul.out >dmul.grp
  16. Makex drem; groups <drem.out >drem.grp
  17. Makex drsh; groups <drsh.out >drsh.grp
  18. Makex dsub; groups <dsub.out >dsub.grp
  19. Makex uinc; groups <uinc.out >uinc.grp
  20. Makex uneg; groups <uneg.out >uneg.grp
  21. Makex upin; groups <upin.out >upin.grp
  22. ###do_all.sh
  23. Install.sh
  24. Mkavg.sh
  25. Alltyp.sh
  26. Runmost.sh
  27. Runmost2.sh
  28. ###install.sh
  29. set -x
  30.  
  31. cc -c calib.c \
  32.     begint.c \
  33.     cputim.c \
  34.     returnp.c \
  35.     error.c \
  36.     fround.c \
  37.     intreg.c \
  38.     sstat.c \
  39.     sauto.c \
  40.     lauto.c \
  41.     dauto.c \
  42.  
  43. ar qc libtim begint.o cputim.o returnp.o fround.o error.o
  44. cc -o calib.x calib.c libtim -lm
  45. calib.x > parms.dat
  46.  
  47. Makex intreg
  48. Makex sstat
  49. Makex sauto
  50. Makex lauto
  51. Makex dauto
  52.  
  53. cc -o fmttbl fmttbl.c libtim
  54. fmttbl intreg.out sstat.out sauto.out lauto.out dauto.out
  55. ###makex.
  56. cc -o $1.x $1.c libtim -lm
  57. echo $1:
  58. $1.x >$1.out
  59. mv $1.x Previous.x
  60. ###mk.qso
  61. echo "Jim - this file also transfers local.h which i forgot to tell you about"
  62. cat >local.h <<!EOF
  63. /* local.h - definitions for use with
  64.  *      Learning to Program in C
  65.  */
  66. #ifndef LOCAL_H
  67. #define LOCAL_H
  68. #include <stdio.h>
  69. #define FAIL        1
  70. #define FOREVER        for (;;)
  71. #define NO            0
  72. #define STDERR        2
  73. #define STDIN        0
  74. #define STDOUT        1
  75. #define SUCCEED        0
  76. #define YES            1
  77. #define bits        ushort
  78. #define bool        int
  79. #define metachar    short
  80. #define tbool        char
  81. #define ushort      unsigned  /* use unsigned short, if you can */
  82. #define void        int        /* delete, if compiler supports void */
  83. #define getln(s, n) ((fgets(s, n, stdin)==NULL) ? EOF : strlen(s))
  84. #define ABS(x)        (((x) < 0) ? -(x) : (x))
  85. #define MAX(x, y)    (((x) < (y)) ? (y) : (x))
  86. #define MIN(x, y)    (((x) < (y)) ? (x) : (y))
  87.  
  88. /* new material - include standard fn declarations */
  89. #include <ctype.h>
  90. #include <math.h>
  91.  
  92. #define TRUE 1
  93. #define FALSE 0
  94.  
  95. #define DIM(a) (sizeof(a) / sizeof(a[0]))
  96. #define SWAP(a, b, t) (t = a, a = b, b = t)
  97. #define LOOPDN(r, n) for (r = n+1; --r > 0; )
  98. #ifndef NDEBUG
  99. #define asserts(cond, str) \
  100.     { if (!(cond)) fprintf(stderr, "Assertion '%s' failed\n", str); }
  101. #else
  102. #define asserts(e, s)
  103. #endif
  104. typedef char *data_ptr;
  105. typedef unsigned size_t;
  106. typedef unsigned index_t;
  107. #define STREQ(s, t) (strcmp(s, t) == 0)
  108. #define STRLT(s, t) (strcmp(s, t) < 0)
  109. #define STRGT(s, t) (strcmp(s, t) > 0)
  110. #define CHAR_BIT 8
  111. #endif
  112. !EOF
  113. cc -o qsortrcm.x qsortrcm.c libtim
  114. qsortrcm.x 100 >qsortrcm.out
  115. qsortrcm.x 1000 >>qsortrcm.out
  116. qsortrcm.x 10000 >>qsortrcm.out
  117. cc -o qsortitm.x qsortitm.c libtim
  118. qsortitm.x 100 >qsortitm.out
  119. qsortitm.x 1000 >>qsortitm.out
  120. qsortitm.x 10000 >>qsortitm.out
  121.  
  122. cc -p -o qsortpro.x qsortpro.c 
  123. qsortpro.x  >>qsortpro.out
  124. prof qsortpro.x >>qsortpro.out
  125. ###runmost.sh
  126. set -x
  127.  
  128. Makex fncall
  129. Makex loops1
  130. Makex loops2
  131. Makex 102
  132. Makex 104
  133. Makex 105
  134. Makex 106
  135. Makex 401
  136. Makex 402
  137. Makex 403
  138. Makex 405
  139. Makex 411
  140. Makex 413
  141. Makex 501
  142. Makex 503
  143. Makex 504
  144. Makex 505
  145. Makex 506
  146. Makex 507
  147. Makex 508
  148. Makex 601
  149. ###runmost2.sh
  150. set -x
  151.  
  152. Makex switch
  153.  
  154. Makex ctypelib
  155. Makex fdlib
  156. Makex mathlib
  157. Makex strlib
  158. Makex stdlib
  159. Makex stdiolib
  160.  
  161. cc -o harness1.x harness1.c; echo harness1; time harness1.x
  162. cc -o harness2.x harness2.c; echo harness2; time harness2.x
  163. cc -o harness3.x harness3.c; echo harness3; time harness3.x
  164. cc -o harness4.x harness4.c libtim; echo harness4; time harness4.x
  165.  
  166. Makex optimtst
  167. ###config.h
  168. /* config.h - configuration data for each environment
  169.  *        This file should either be customized to the intended
  170.  *        compiler/machine environment, or parameterized via -D flags
  171.  *        on the compile step:
  172.  *        -D USHORT    if compiler supports unsigned short
  173.  *        -D UTINY    if compiler supports unsigned char
  174.  *        -D VOID        if compiler supports void
  175.  *        -D ULONG    if compiler supports unsigned LONG
  176.  */
  177. #define UTINY    /* UNIX System 3 ff */
  178. #define USHORT    /* UNIX System 3 ff */
  179. #define ULONG    /* UNIX System 3 ff */
  180. #define VOID    /* UNIX System 3 ff */
  181. #ifdef USHORT
  182. typedef unsigned short ushort;
  183. #else
  184. typedef unsigned ushort;    /* assumes short == int */
  185. #endif
  186. #ifdef UTINY
  187. typedef unsigned char utiny;
  188. #endif
  189. #ifdef ULONG
  190. typedef unsigned long ulong;
  191. #endif
  192. #ifndef VOID
  193. #define void int
  194. #endif
  195. #define MINSAM 2e6        /* minimum timing sample (usec) */
  196. #define NTRY 100        /* maximum no of code excerpts per file */
  197. #define FR_ANCHOR arg1    /* what is the "frame anchor": arg1 or var1 */
  198. #define RETOFFSET (-1)    /* offset of return pointer
  199.                            relative to frame anchor */
  200. #define JUNKFILE "/dev/null"
  201. ###cputim.c
  202. /* cputim - UNIX version
  203.  */
  204.  
  205.  
  206. #define UTIME (tbufb.ut - tbufa.ut + tbufb.cut - tbufa.cut)
  207. #define STIME (tbufb.st - tbufa.st + tbufb.cst - tbufa.cst)
  208.  
  209. typedef struct tbuf {    /* UNIX V7 ff   */
  210.     long ut, st;
  211.     long cut, cst;
  212. } TBUF;
  213.  
  214. long times();
  215.  
  216. /*
  217.  * cputim - return (in ticks) CPU time since last call
  218.  */
  219. long cputim()
  220. {
  221.     long ret;
  222.     long ut1, st1, i;
  223.     static TBUF tbufa = {0, 0, 0, 0};
  224.     static TBUF tbufb = {0, 0, 0, 0};
  225.  
  226.     times(&tbufb);
  227.     ut1 = UTIME;
  228.     st1 = STIME;
  229.     ret = (ut1 + st1);
  230.  
  231.     tbufa = tbufb;
  232.     return (ret);
  233. }
  234. ###cputim.h
  235. /* cputim.h  */
  236. #ifndef TIME_H
  237. #define TIME_H
  238. #define CLOCK_TICKS_PER_SECOND 60
  239. typedef long cputim_t;
  240. extern cputim_t cputim();
  241. #endif
  242. ###readme.
  243. to run the timing suite on unix
  244.  
  245. the source disk requires these steps to run:
  246.  
  247. the procedure involves dozens of compiles.
  248. the stdiolib test needs lots of free disk space, 200 K would suffice.
  249.  
  250.  
  251. run  install.sh
  252.  
  253.     this produces the tables for basic operations, and creates the
  254.     object files needed for the other steps.
  255.  
  256. run  mkavg.sh
  257.  
  258.     this does some simple "cluster analysis" to produce an
  259.     "average time" estimate for each data category.  any time
  260.     that is within a factor of 3 of the average is included in
  261.     the average; the out-of-range times are listed individually.
  262.  
  263. run  runmost.sh
  264.  
  265.     this times various control structures
  266.  
  267. run  runmost2.sh
  268.  
  269.     more control structures, library tests, simple timing harnesses
  270.  
  271. run  alltyp.sh
  272.  
  273.     this times each C operator on all the basic types, and
  274.     produces a "grouping" of significantly different categories.
  275.     (in other words, what combintions of type and storage class
  276.     affect the timing of each operator.)
  277.  
  278. call with any questions.
  279.  
  280. see the appendix of Efficient C for further instructions.
  281.  
  282.  
  283. tom plum  609-927-3770
  284. ###EOF
  285.