How much Optimization should be done

Bob Stout Bob.Stout at p6.f506.n106.z1.fidonet.org
Mon Jun 12 21:08:51 AEST 1989


About 2 years ago, this topic came up on FidoNet. Using the following  
(admittedly rigged) benchmark, I tested all of the technology available to me.

main()
{
   char string[30];
   int a = 2, b = 3, c = 5;
   int d, data[30], i, j, k;

   for (i = 0; i < (a + b) * c; )
   {
      k = 12 / b;
      data[i] = k;
      i += a/2;
      j = data[i] * b;
   }
   for (i = 0; i < 10; i++)
   {
      if (i < 5)
         d = a * b + i;
      else
      c = a * b + i;
      string[i * a + b] = (char)(c + d);
   }
   do
   {
      if (data[k] == c)
         data[c - b - a] = b - a;
      else
         data[c - b - a] = a - b;
      if (b > c)
         data[b - a] = c - b - a;
      else
         string[a] = string[b];
      k = (int)string[a];
   } while (k);
}

Here is the list with timings for the revised benchmarks executing 100,000  
iterations and the new assembly sizes (where available - see notes).

        Machine/OS              Asm size        Time to execute (1)
        ----------------------  --------------  -------------------
        VAX 780 VMS              89 lines (2,3)  12.?? (4)
        MicroVAX Unix system V   91 lines       178.80 (5)
        Sun 3 Unix 4.2 BSD      125 lines        41.9
        Pyramid Unix 4.3 BSD    108 lines        91.81
        Cray 2 UniCOS           347 lines         5.97
        Cray X-MP 48 UniCOS      - (6) -          5.29
        Datalight Optimum-C     100 lines (2)
        8 MHz AT DOS 3.1                         24.33 sec.

NOTES: (1) timing in sec. for 100,000 iterations (except where
           noted) for a single dedicated user 
       (2) commented w/ C source
       (3) asm source in OPTBNCH.ARC is for single iteration
       (4) very coarse timing - only 1 user
       (5) timing is for 10K iterations (17.88 sec.) * 10
       (6) Beta test vectorizing C compiler - asm not available

Again note that this is two-year old technology! Still, the main things that  
have changed are that the Cray's UniCOS compiler is out of beta test and  
available on the Y-MP and the Datalight DOS compiler has been superceded by  
the new Zortech compiler.



More information about the Comp.lang.c mailing list