Compilers and Performance

dstubbs@garden.csc.calpoly.edu (Dan Stubbs)
Wed, 18 Oct 1995 19:19:19 GMT

          From comp.compilers

Related articles
Compilers and Performance dstubbs@garden.csc.calpoly.edu (1995-10-18)
Re: Compilers and Performance pardo@cs.washington.edu (1995-10-23)
| List of all articles for this month |

Newsgroups: comp.compilers
From: dstubbs@garden.csc.calpoly.edu (Dan Stubbs)
Keywords: performance, question, comment
Organization: Cal Poly, State University
Date: Wed, 18 Oct 1995 19:19:19 GMT

The following shows the times to perform a sequential search on a
RISC workstation using two different compilers and either full or no
optimization for each compiler.


Sequential search here means searching for all array values and one
value between each pair of array values. The search is on an array
(of size 3,000). Similar results are obtained for searching a linked
list. The search algorithm is not recursive.


Sequential search was picked in order to have relatively simple code.
The language is C.


      Compiler Optimization Time
    ----------+--------------+------
          1 none 244
          1 full 38
          2 none 321
          2 full 100


The experiment was run on two other workstations and similar results
were obtained. I guess I am surprised by the major difference in
performance where the code is simple and the only variable is the
compiler. Should I be?


Here is the search code.
/*----------------------------------*/
int issearch (int A[], int n, int t) {
      int k = 0;
      while (k < n) {
            if (t == A[k]) return k;
            k++;
      }
      return -1;
}
/*----------------------------------*/
[I'm not very surprised. If you look at the assembler from each compiler,
you'll probably be able to see the differences in the optimization they do.
-John]
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.