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

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