home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / ins_msc / imc9106 / testfunc.c < prev   
Text File  |  1991-05-09  |  3KB  |  110 lines

  1. /*******************************************************************
  2. * TESTFUNC.C - This file contains all of the test functions used   *
  3. * in the article "More loop optimization techniques" in the IMC    *
  4. * May 1991 issue.                                                  *
  5. *                                                                  *
  6. * There are 3 sets of test functions, corresponding to the test    *
  7. * cases discussed in the article. By uncommenting one of the       *
  8. * #define statements below you can choose which set of test        *
  9. * functions to run. For example, to test the code from Figures 1a  *
  10. * and 1b, you would uncomment the line: "#define FIGURE1 0"        *
  11. *******************************************************************/
  12.  
  13. /*-------- Select test functions by uncommenting ONE of these ----*/
  14. #define FIGURE1 0
  15. //#define FIGURE2 0
  16. //#define FIGURE3 0
  17.  
  18. /*-------- Global variables used by test functions ---------------*/
  19. int x[100], y[100], z[100];
  20.  
  21. /*******************************************************************
  22. * This empty function is used to determine the standard function   *
  23. * call overhead.                                                   *
  24. *******************************************************************/
  25. void emptyfunc(void)
  26.     {
  27.     }
  28.  
  29. /*******************************************************************
  30. * These functions test the code shown in Figures 1a and 1b         *
  31. *******************************************************************/
  32. #ifdef FIGURE1
  33. void testfunc1( void )
  34.     {
  35.     int counter;
  36.  
  37.     for (counter = 0 ; counter < 100; counter++)
  38.         z[counter] = (y[counter] * 8);
  39.     }
  40.  
  41. void testfunc2( void )
  42.     {
  43.     int counter;
  44.  
  45.     for (counter = 0 ; counter < 100; counter += 2)
  46.         {
  47.         z[counter] = (y[counter] * 8);
  48.         z[counter + 1] = (y[counter + 1] * 8);
  49.         }
  50.     }
  51. #endif
  52.  
  53. /*******************************************************************
  54. * These functions test the code shown in Figures 2a and 2b         *
  55. *******************************************************************/
  56. #ifdef FIGURE2
  57. void testfunc1( void )
  58.     {
  59.     int counter;
  60.  
  61.     for (counter = 0 ; counter < 50; counter += 2)
  62.         {
  63.         z[counter] = (y[counter] * 8);
  64.         z[counter + 1] = (y[counter + 1] * 8);
  65.         }
  66.     }
  67.  
  68. void testfunc2( void )
  69. {
  70.     int counter;
  71.     register int *p = z;
  72.     register int *q = y;
  73.  
  74.     for (counter = 0 ; counter < 50; counter += 2)
  75.         {
  76.         *p = (*q << 3);
  77.         p++;
  78.         q++;
  79.         *p = (*q << 3);
  80.         }
  81. }
  82. #endif
  83.  
  84. /*******************************************************************
  85. * These functions test the code shown in Figures 3a and 3b         *
  86. *******************************************************************/
  87. #ifdef FIGURE3
  88. void testfunc1( void )
  89.     {
  90.     int counter;
  91.  
  92.     for (counter = 0 ; counter < 50; counter++)
  93.         z[counter] = (y[counter] * 8);
  94.  
  95.     for (counter = 0 ; counter < 50; counter++)
  96.         x[counter] = z[counter] + y[counter];
  97.     }
  98.  
  99. void testfunc2( void )
  100.     {
  101.     int counter;
  102.  
  103.     for (counter = 0 ; counter < 50; counter++)
  104.         {
  105.         z[counter] = (y[counter] * 8);
  106.         x[counter] = z[counter] + y[counter];
  107.         }
  108.     }
  109. #endif
  110.