cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leo Sutic" <leo.su...@inspireinfrastructure.com>
Subject RE: [Heads Up] Utility for efficiency
Date Fri, 18 Jan 2002 15:13:29 GMT


> From: Berin Loritsch [mailto:bloritsch@apache.org]
>
> ------------------------------------------------------------------
> import java.util.*;
> import org.apache.avalon.excalibur.collections.ArrayStack;
>
> public class StackTest
> {
>   public static void main(String[] args)
>   {
>    int lInitialSize = Integer.parseInt(args[0]);
>    int lIterations = Integer.parseInt(args[1]);
>    ArrayList lArrayList = new ArrayList(lInitialSize + 1);
>    LinkedList lLinkedList = new LinkedList();
>    Stack lStack = new Stack();
>    ArrayStack lArrayStack = new ArrayStack();
>    long lBegin, lEnd;
>
>    for (int i = 0; i < lInitialSize; i++)
>    {
>     lArrayList.add(new Integer(i));
>     lLinkedList.add(new Integer(i));
>     lStack.push(new Integer(i));
>     lArrayStack.push(new Integer(i));
>    }
>
>    lBegin = System.currentTimeMillis();
>    for (int i = 0; i < lIterations; i++)
>    {
>     lArrayList.add(new Integer(i));  // Add to the tail
>     lArrayList.remove(lInitialSize);  // Remove from the tail
>    }

Just looking at the code - this only adds and removes the top item on the
stack,
which doesn't really exercise it properly. A FIFO is completely exercised
by the add one, remove one, but a stack is very nearly static...

As an arraylist will never shrink, while a linked list will, I wonder
how the contestants handle memory use.

(And, yes, I may make the required changes and try it.)

/LS



---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Mime
View raw message