From: William D Clinger
Subject: Re: Bottleneck rule
Date: 
Message-ID: <dd9784f2-65c5-4002-a3e6-6ce99c6eafbb@j22g2000hsf.googlegroups.com>
Francogrex wrote:
> I wrote a function which loops through a long list of strings (about a
> 10000) modifies some according to some specified rules and finally it
> groups similar strings together. When this is run (even loaded from a
> compiled .fas file), it takes about 2 hours to complete (it's true at
> some level there is an iteration through an array of 10 million rows
> (10000*10000)....

First, I agree with Pascal's and Rainer's comments.
In addition, I noticed this:

  (dotimes (i (array-dimension store 0))
    (setf ls (append ls (list (aref store i 0)))))

That looks suspiciously like one of the classic mistakes
that beginning programmers make when they set out to
concatenate a large number of strings.  Here, for example,
is a really bad way to concatenate an array of strings in
Java:

  // Given an array of strings, returns their concatenation.

  String concat (String[] strings) {
      String result = "";
      for (int i = 0; i < strings.length; i = i + 1)
          result = result + strings[i];
      return result;
  }

If n is the number of characters in the result, then that
code requires Theta(n^2) time to compute the result, when
the result is computable in Theta(n) time:

  String concat (String[] strings) {
      StringBuilder result = new StringBuilder();
      for (int i = 0; i < strings.length; i = i + 1)
          result.append(strings[i]);
      return result.toString();
  }

That is a probable cause of your program's inefficiency.
There are likely to be other causes as well.

Will