FileDocCategorySizeDatePackage
LinkedListTest.javaAPI DocAndroid 1.5 API16709Wed May 06 22:42:02 BST 2009com.android.unit_tests

LinkedListTest

public class LinkedListTest extends android.test.PerformanceTestBase
This class contains performance tests for methods in java.util.LinkedList

Fields Summary
public static final int
ITERATIONS
LinkedList
mLinkedList
Constructors Summary
Methods Summary
protected voidsetUp()


    
         
        super.setUp();
        mLinkedList = new LinkedList();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            mLinkedList.add(i);
        }
    
public intstartPerformance(PerformanceTestCase.Intermediates intermediates)

        intermediates.setInternalIterations(ITERATIONS);
        return 0;
    
public voidtestLinkedListAdd()

        LinkedList<Integer> list = new LinkedList();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            list.add(i);
            list.add(i);
            list.add(i);
            list.add(i);
            list.add(i);
            list.add(i);
            list.add(i);
            list.add(i);
            list.add(i);
            list.add(i);
        }
    
public voidtestLinkedListAdd1()

        LinkedList<Integer> list = new LinkedList();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            list.add(0, i);
            list.add(0, i);
            list.add(0, i);
            list.add(0, i);
            list.add(0, i);
            list.add(0, i);
            list.add(0, i);
            list.add(0, i);
            list.add(0, i);
            list.add(0, i);
        }
    
public voidtestLinkedListAddAll()

        LinkedList<Integer> mList = mLinkedList;
        boolean flag;
        LinkedList<Integer> list = new LinkedList();
        for (int i = 10; i > 0; i--) {
            flag = list.addAll(mList);
            flag = list.addAll(mList);
            flag = list.addAll(mList);
            flag = list.addAll(mList);
            flag = list.addAll(mList);
            flag = list.addAll(mList);
            flag = list.addAll(mList);
            flag = list.addAll(mList);
            flag = list.addAll(mList);
            flag = list.addAll(mList);
        }
    
public voidtestLinkedListAddAll1()

        LinkedList<Integer> mList = new LinkedList();
        int pos = 0;
        boolean flag;
        LinkedList<Integer> list = mLinkedList;
        for (int i = 0; i < 10; i++) {
            flag = mList.addAll(pos, list);
            flag = mList.addAll(pos, list);
            flag = mList.addAll(pos, list);
            flag = mList.addAll(pos, list);
            flag = mList.addAll(pos, list);
            flag = mList.addAll(pos, list);
            flag = mList.addAll(pos, list);
            flag = mList.addAll(pos, list);
            flag = mList.addAll(pos, list);
            flag = mList.addAll(pos, list);
        }
    
public voidtestLinkedListAddFirst()

        LinkedList<Integer> list = new LinkedList();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            list.addFirst(i);
            list.addFirst(i);
            list.addFirst(i);
            list.addFirst(i);
            list.addFirst(i);
            list.addFirst(i);
            list.addFirst(i);
            list.addFirst(i);
            list.addFirst(i);
            list.addFirst(i);
        }
    
public voidtestLinkedListAddLast()

        LinkedList<Integer> list = new LinkedList();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            list.addLast(i);
            list.addLast(i);
            list.addLast(i);
            list.addLast(i);
            list.addLast(i);
            list.addLast(i);
            list.addLast(i);
            list.addLast(i);
            list.addLast(i);
            list.addLast(i);
        }
    
public voidtestLinkedListClone()

        Object rObj;
        LinkedList<Integer> list = mLinkedList;
        for (int i = 100; i > 0; i--) {
            rObj = list.clone();
            rObj = list.clone();
            rObj = list.clone();
            rObj = list.clone();
            rObj = list.clone();
            rObj = list.clone();
            rObj = list.clone();
            rObj = list.clone();
            rObj = list.clone();
            rObj = list.clone();
        }
    
public voidtestLinkedListContains()

        boolean flag;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = list.contains(i);
            flag = list.contains(i);
            flag = list.contains(i);
            flag = list.contains(i);
            flag = list.contains(i);
            flag = list.contains(i);
            flag = list.contains(i);
            flag = list.contains(i);
            flag = list.contains(i);
            flag = list.contains(i);
        }
    
public voidtestLinkedListElement()

        int element;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            element = list.element();
            element = list.element();
            element = list.element();
            element = list.element();
            element = list.element();
            element = list.element();
            element = list.element();
            element = list.element();
            element = list.element();
            element = list.element();
        }
    
public voidtestLinkedListGet()

        int element;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            element = list.get(i);
            element = list.get(i);
            element = list.get(i);
            element = list.get(i);
            element = list.get(i);
            element = list.get(i);
            element = list.get(i);
            element = list.get(i);
            element = list.get(i);
            element = list.get(i);
        }
    
public voidtestLinkedListHashcode()

        int element;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            element = list.hashCode();
            element = list.hashCode();
            element = list.hashCode();
            element = list.hashCode();
            element = list.hashCode();
            element = list.hashCode();
            element = list.hashCode();
            element = list.hashCode();
            element = list.hashCode();
            element = list.hashCode();
        }
    
public voidtestLinkedListIndexOf()

        int index;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            index = list.indexOf(0);
            index = list.indexOf(0);
            index = list.indexOf(0);
            index = list.indexOf(0);
            index = list.indexOf(0);
            index = list.indexOf(0);
            index = list.indexOf(0);
            index = list.indexOf(0);
            index = list.indexOf(0);
            index = list.indexOf(0);

        }
    
public voidtestLinkedListIsEmpty()

        boolean flag;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = list.isEmpty();
            flag = list.isEmpty();
            flag = list.isEmpty();
            flag = list.isEmpty();
            flag = list.isEmpty();
            flag = list.isEmpty();
            flag = list.isEmpty();
            flag = list.isEmpty();
            flag = list.isEmpty();
            flag = list.isEmpty();
        }
    
public voidtestLinkedListIterator()

        ListIterator iterator;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            iterator = list.listIterator();
            iterator = list.listIterator();
            iterator = list.listIterator();
            iterator = list.listIterator();
            iterator = list.listIterator();
            iterator = list.listIterator();
            iterator = list.listIterator();
            iterator = list.listIterator();
            iterator = list.listIterator();
            iterator = list.listIterator();
        }
    
public voidtestLinkedListLastIndexOf()

        int index;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            index = list.lastIndexOf(0);
            index = list.lastIndexOf(0);
            index = list.lastIndexOf(0);
            index = list.lastIndexOf(0);
            index = list.lastIndexOf(0);
            index = list.lastIndexOf(0);
            index = list.lastIndexOf(0);
            index = list.lastIndexOf(0);
            index = list.lastIndexOf(0);
            index = list.lastIndexOf(0);
        }
    
public voidtestLinkedListOffer()

        LinkedList<Integer> list = new LinkedList();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            list.offer(i);
            list.offer(i);
            list.offer(i);
            list.offer(i);
            list.offer(i);
            list.offer(i);
            list.offer(i);
            list.offer(i);
            list.offer(i);
            list.offer(i);
        }
    
public voidtestLinkedListPeek()

        int element;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            element = list.peek();
            element = list.peek();
            element = list.peek();
            element = list.peek();
            element = list.peek();
            element = list.peek();
            element = list.peek();
            element = list.peek();
            element = list.peek();
            element = list.peek();
        }
    
public voidtestLinkedListPoll()

        int element;
        LinkedList<Integer> list = new LinkedList(mLinkedList);
        for (int i = 10; i > 0; i--) {
            element = list.poll();
            element = list.poll();
            element = list.poll();
            element = list.poll();
            element = list.poll();
            element = list.poll();
            element = list.poll();
            element = list.poll();
            element = list.poll();
            element = list.poll();
        }
    
public voidtestLinkedListRemove()

        int index;
        LinkedList<Integer> list = new LinkedList(mLinkedList);
        for (int i = 10; i > 0; i--) {
            index = list.remove();
            index = list.remove();
            index = list.remove();
            index = list.remove();
            index = list.remove();
            index = list.remove();
            index = list.remove();
            index = list.remove();
            index = list.remove();
            index = list.remove();
        }
    
public voidtestLinkedListRemove1()

        int index;
        LinkedList<Integer> list = new LinkedList(mLinkedList);
        for (int i = 10; i > 0; i--) {
            index = list.remove(0);
            index = list.remove(0);
            index = list.remove(0);
            index = list.remove(0);
            index = list.remove(0);
            index = list.remove(0);
            index = list.remove(0);
            index = list.remove(0);
            index = list.remove(0);
            index = list.remove(0);
        }
    
public voidtestLinkedListRemove2()

        LinkedList<String> list;
        String s = new String("a");
        list = new LinkedList();
        for (int j = 1000; j > 0; j--) {
            list.add("a");
            list.add("b");
        }
        boolean flag;
        for (int i = 10; i > 0; i--) {
            flag = list.remove(s);
            flag = list.remove(s);
            flag = list.remove(s);
            flag = list.remove(s);
            flag = list.remove(s);
            flag = list.remove(s);
            flag = list.remove(s);
            flag = list.remove(s);
            flag = list.remove(s);
            flag = list.remove(s);
        }
    
public voidtestLinkedListRemoveFirst()

        int index;
        LinkedList<Integer> list = new LinkedList(mLinkedList);
        for (int i = 10; i > 0; i--) {
            index = list.removeFirst();
            index = list.removeFirst();
            index = list.removeFirst();
            index = list.removeFirst();
            index = list.removeFirst();
            index = list.removeFirst();
            index = list.removeFirst();
            index = list.removeFirst();
            index = list.removeFirst();
            index = list.removeFirst();
        }
    
public voidtestLinkedListRemoveLast()

        int index;
        LinkedList<Integer> list = new LinkedList(mLinkedList);
        for (int i = 10; i > 0; i--) {
            index = list.removeLast();
            index = list.removeLast();
            index = list.removeLast();
            index = list.removeLast();
            index = list.removeLast();
            index = list.removeLast();
            index = list.removeLast();
            index = list.removeLast();
            index = list.removeLast();
            index = list.removeLast();
        }
    
public voidtestLinkedListSet()

        LinkedList<Integer> list = mLinkedList;
        int value1 = 500, value2 = 0;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            list.set(value1, value2);
            list.set(value1, value2);
            list.set(value1, value2);
            list.set(value1, value2);
            list.set(value1, value2);
            list.set(value1, value2);
            list.set(value1, value2);
            list.set(value1, value2);
            list.set(value1, value2);
            list.set(value1, value2);
        }
    
public voidtestLinkedListSize()

        LinkedList<Integer> list = mLinkedList;
        int len;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            len = list.size();
            len = list.size();
            len = list.size();
            len = list.size();
            len = list.size();
            len = list.size();
            len = list.size();
            len = list.size();
            len = list.size();
            len = list.size();
        }
    
public voidtestLinkedListToArray()

        Object array;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            array = list.toArray();
            array = list.toArray();
            array = list.toArray();
            array = list.toArray();
            array = list.toArray();
            array = list.toArray();
            array = list.toArray();
            array = list.toArray();
            array = list.toArray();
            array = list.toArray();
        }
    
public voidtestLinkedListToArray1()

        Integer[] rArray = new Integer[100];
        Integer[] array;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            array = list.toArray(rArray);
            array = list.toArray(rArray);
            array = list.toArray(rArray);
            array = list.toArray(rArray);
            array = list.toArray(rArray);
            array = list.toArray(rArray);
            array = list.toArray(rArray);
            array = list.toArray(rArray);
            array = list.toArray(rArray);
            array = list.toArray(rArray);
        }
    
public voidtestLinkedListToString()

        String str;
        LinkedList<Integer> list = mLinkedList;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            str = list.toString();
            str = list.toString();
            str = list.toString();
            str = list.toString();
            str = list.toString();
            str = list.toString();
            str = list.toString();
            str = list.toString();
            str = list.toString();
            str = list.toString();
        }