home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 161_01 / alltyp.h < prev    next >
C/C++ Source or Header  |  1985-08-29  |  4KB  |  163 lines

  1. /* alltyp - run timing for all variable types
  2.  */
  3. #include "config.h"
  4.  
  5. double ed0 = 0, ed1 = 63, ed2 = 15;
  6. float ef0 = 0, ef1 = 63, ef2 = 15;
  7. char ec0 = 0, ec1 = 63, ec2 = 15;
  8. short es0 = 0, es1 = 63, es2 = 15;
  9. long el0 = 0, el1 = 63, el2 = 15;
  10. ushort eus0 = 0, eus1 = 63, eus2 = 15; 
  11. static double sd0 = 0, sd1 = 63, sd2 = 15;
  12. static float sf0 = 0, sf1 = 63, sf2 = 15;
  13. static char sc0 = 0, sc1 = 63, sc2 = 15;
  14. static short ss0 = 0, ss1 = 63, ss2 = 15;
  15. static long sl0 = 0, sl1 = 63, sl2 = 15;
  16. #ifdef UTINY
  17.  utiny euc0 = 0, euc1 = 63, euc2 = 15; 
  18.  static utiny suc0 = 0, suc1 = 63, suc2 = 15; 
  19. #endif
  20. static ushort sus0 = 0, sus1 = 63, sus2 = 15; 
  21. #ifdef ULONG
  22.  ulong eul0 = 0, eul1 = 63, eul2 = 15; 
  23.  static ulong sul0 = 0, sul1 = 63, sul2 = 15; 
  24. #endif
  25. /* #include "timer1.h" */
  26. #include <stdio.h>
  27.  
  28. typedef int bool;
  29. #define NO  0
  30. #define YES 1
  31. #define MAXITER  10000000
  32.  
  33. #define SKIP 0
  34. #define NOASST 1
  35. #define REGASST 2
  36. #define DBLASST 3
  37. #define CDOWN(a, b) for (a = (b)+1; --a > 0;  )
  38. #define DO_SKIP(S) \
  39.     t_s=S; \
  40.     t_type = SKIP; \
  41.     begintim(0); \
  42.     if (0) { 
  43. #define DO_STMT(S) \
  44.     t_s=S; \
  45.     t_type = NOASST; \
  46.     if (t_sample[t_try] < t_minsam) { \
  47.     begintim(0); \
  48.     CDOWN(t_major, t_majrtry) CDOWN(t_minor, t_minrtry)
  49. #define DO_FEXPR(S) \
  50.     t_s=S; \
  51.     t_type = DBLASST; \
  52.     if (t_sample[t_try] < t_minsam) { \
  53.     begintim(0); \
  54.     CDOWN(t_major, t_majrtry) CDOWN(t_minor, t_minrtry)  t_dbl = 
  55. #define DO_IEXPR(S) \
  56.     t_s=S; \
  57.     t_type = REGASST; \
  58.     if (t_sample[t_try] < t_minsam) { \
  59.     begintim(0); \
  60.     CDOWN(t_major, t_majrtry) CDOWN(t_minor, t_minrtry)  t_reg = 
  61. #define OD ;} endtim(0);  ++t_try;
  62.  
  63. extern char *t_s;            /* description of this try */
  64. extern long t_reps;            /* number of samples this iteration */
  65. extern short t_try;            /* which trial number is being done next */
  66. extern short t_type;            /* selection of timing method */
  67. extern double t_mintry;        /* min samples this iteration */
  68. extern double t_minsam;        /* desired minimum samples */
  69. extern double t_sample[];    /* actual samples for each try */
  70.  
  71. static double t_dbl = 0;            /* target for forced double assigns */
  72. static unsigned t_majrtry = 0;    /* major loop limit */
  73. static unsigned t_major = 0;        /* major loop variable */
  74. static unsigned t_minrtry = 0;    /* minor loop limit */
  75. static unsigned t_minor = 0;        /* minor loop variable */
  76. static void timeall();
  77. main()
  78.     {
  79.     bool more;
  80.     short i;
  81.  
  82.     t_reps = 1;
  83.     do
  84.         {
  85.         t_try = 0;
  86.         if (t_reps <= 10000)
  87.             {
  88.             t_minrtry = t_reps;
  89.             t_majrtry = 1;
  90.             }
  91.         else
  92.             {
  93.             t_minrtry = 10000;
  94.             t_majrtry = t_reps / 10000;
  95.             }
  96.         timeall();
  97.         t_reps *= 10;
  98.         more = NO;
  99.         for (i = 0; i < t_try; ++i)
  100.             if (t_sample[i] < t_minsam)
  101.                 more = YES;
  102.         } while (more && t_reps <= MAXITER);
  103.     report();
  104.     }
  105. static void timeall()
  106.     {
  107.     register int t_reg;        /* target for forced assigns */
  108. /* end of "timer1.h" */
  109. double ad0 = 0, ad1 = 63, ad2 = 15;
  110. float af0 = 0, af1 = 63, af2 = 15;
  111. char ac0 = 0, ac1 = 63, ac2 = 15;
  112. short as0 = 0, as1 = 63, as2 = 15;
  113. long al0 = 0, al1 = 63, al2 = 15;
  114. #ifdef UTINY
  115.  utiny auc0 = 0, auc1 = 63, auc2 = 15; 
  116. #endif
  117. ushort aus0 = 0, aus1 = 63, aus2 = 15; 
  118. #ifdef ULONG
  119.  ulong aul0 = 0, aul1 = 63, aul2 = 15; 
  120. #endif
  121. register int ri1 = 63, ri2 = 15;
  122.  
  123. #ifndef NODOUBLE
  124. DO_FEXPR("a   f")    OP(af1, af2);    OD;
  125. DO_FEXPR("a   d")    OP(ad1, ad2);    OD;
  126. DO_FEXPR("s   f")    OP(sf1, sf2);    OD;
  127. DO_FEXPR("s   d")    OP(sd1, sd2);    OD;
  128. DO_FEXPR("e   f")    OP(ef1, ef2);    OD;
  129. DO_FEXPR("e   d")    OP(ed1, ed2);    OD;
  130. #endif
  131. DO_IEXPR("e   c")    OP(ec1, ec2);    OD;
  132. DO_IEXPR("e   s")    OP(es1, es2);    OD;
  133. DO_IEXPR("e   l")    OP(el1, el2);    OD;
  134. #ifdef UTINY
  135.  DO_IEXPR("e u c")    OP(euc1, euc2);    OD; 
  136. #endif
  137. DO_IEXPR("e u s")    OP(eus1, eus2);    OD;
  138. #ifdef ULONG
  139.  DO_IEXPR("e u l")    OP(eul1, eul2);    OD; 
  140. #endif
  141. DO_IEXPR("s   c")    OP(sc1, sc2);    OD;
  142. DO_IEXPR("s   s")    OP(ss1, ss2);    OD;
  143. DO_IEXPR("s   l")    OP(sl1, sl2);    OD;
  144. #ifdef UTINY
  145.  DO_IEXPR("s u c")    OP(suc1, suc2);    OD; 
  146. #endif
  147. DO_IEXPR("s u s")    OP(sus1, sus2);    OD;
  148. #ifdef ULONG
  149.  DO_IEXPR("s u l")    OP(sul1, sul2);    OD; 
  150. #endif
  151. DO_IEXPR("a   c")    OP(ac1, ac2);    OD;
  152. DO_IEXPR("a   s")    OP(as1, as2);    OD;
  153. DO_IEXPR("a   l")    OP(al1, al2);    OD;
  154. #ifdef UTINY
  155.  DO_IEXPR("a u c")    OP(auc1, auc2);    OD; 
  156. #endif
  157. DO_IEXPR("a u s")    OP(aus1, aus2);    OD;
  158. #ifdef ULONG
  159.  DO_IEXPR("a u l")    OP(aul1, aul2);    OD; 
  160. #endif
  161. DO_IEXPR("r   i")    OP(ri1, ri2);    OD;
  162. }
  163.