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

VectorTest

public class VectorTest extends android.test.PerformanceTestBase
Basic Performance Tests for java.util.Vector

Fields Summary
public static final int
ITERATIONS
private Vector
mVector
private Vector
mStrVector
private String
mTestString
Constructors Summary
Methods Summary
public voidVectorAddAll()

        Vector<Integer> vector = new Vector(), vector1 = mVector;

        boolean flag;
        for (int i = 10; i > 0; i--) {
            flag = vector.addAll(vector1);
            flag = vector.addAll(vector1);
            flag = vector.addAll(vector1);
            flag = vector.addAll(vector1);
            flag = vector.addAll(vector1);
            flag = vector.addAll(vector1);
            flag = vector.addAll(vector1);
            flag = vector.addAll(vector1);
            flag = vector.addAll(vector1);
            flag = vector.addAll(vector1);
        }
    
public voidVectorRemove1()

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

        Vector<Integer> vector = new Vector(mVector);
        for (int i = 10; i > 0; i--) {
            vector.removeElementAt(i);
            vector.removeElementAt(i);
            vector.removeElementAt(i);
            vector.removeElementAt(i);
            vector.removeElementAt(i);
            vector.removeElementAt(i);
            vector.removeElementAt(i);
            vector.removeElementAt(i);
            vector.removeElementAt(i);
            vector.removeElementAt(i);
        }
    
protected voidsetUp()


    
         
        super.setUp();
        mVector = new Vector();
        mStrVector = new Vector();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            assertTrue(mVector.add(i));
            assertTrue(mStrVector.add(Integer.toString(i)));
        }
    
public intstartPerformance(PerformanceTestCase.Intermediates intermediates)

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

        Vector<Integer> vector = new Vector();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            vector.add(i);
            vector.add(i);
            vector.add(i);
            vector.add(i);
            vector.add(i);
            vector.add(i);
            vector.add(i);
            vector.add(i);
            vector.add(i);
            vector.add(i);
        }
    
public voidtestVectorAdd1()

        Vector<Integer> vector = new Vector();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            vector.add(0, i);
            vector.add(0, i);
            vector.add(0, i);
            vector.add(0, i);
            vector.add(0, i);
            vector.add(0, i);
            vector.add(0, i);
            vector.add(0, i);
            vector.add(0, i);
            vector.add(0, i);
        }
    
public voidtestVectorAddAll1()

        Vector<Integer> mEmptyVector = new Vector();
        boolean flag;
        int pos = 0;
        Vector<Integer> vector1 = mVector;
        Vector<Integer> vector = mEmptyVector;
        for (int i = 10; i > 0; i--) {
            flag = vector.addAll(pos, vector1);
            flag = vector.addAll(pos, vector1);
            flag = vector.addAll(pos, vector1);
            flag = vector.addAll(pos, vector1);
            flag = vector.addAll(pos, vector1);
            flag = vector.addAll(pos, vector1);
            flag = vector.addAll(pos, vector1);
            flag = vector.addAll(pos, vector1);
            flag = vector.addAll(pos, vector1);
            flag = vector.addAll(pos, vector1);
        }
    
public voidtestVectorAddElement()

        int element;
        Vector<String> vector = mStrVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            vector.addElement(mTestString);
            vector.addElement(mTestString);
            vector.addElement(mTestString);
            vector.addElement(mTestString);
            vector.addElement(mTestString);
            vector.addElement(mTestString);
            vector.addElement(mTestString);
            vector.addElement(mTestString);
            vector.addElement(mTestString);
            vector.addElement(mTestString);
        }
    
public voidtestVectorCapacity()

        int capacity;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            capacity = vector.capacity();
            capacity = vector.capacity();
            capacity = vector.capacity();
            capacity = vector.capacity();
            capacity = vector.capacity();
            capacity = vector.capacity();
            capacity = vector.capacity();
            capacity = vector.capacity();
            capacity = vector.capacity();
            capacity = vector.capacity();
        }
    
public voidtestVectorClone()

        Object obj;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            obj = vector.clone();
            obj = vector.clone();
            obj = vector.clone();
            obj = vector.clone();
            obj = vector.clone();
            obj = vector.clone();
            obj = vector.clone();
            obj = vector.clone();
            obj = vector.clone();
            obj = vector.clone();
        }
    
public voidtestVectorContains()

        boolean flag;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = vector.contains(i);
            flag = vector.contains(i);
            flag = vector.contains(i);
            flag = vector.contains(i);
            flag = vector.contains(i);
            flag = vector.contains(i);
            flag = vector.contains(i);
            flag = vector.contains(i);
            flag = vector.contains(i);
            flag = vector.contains(i);
        }
    
public voidtestVectorCopyInto()

        Integer[] rArray = new Integer[ITERATIONS];
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            vector.copyInto(rArray);
            vector.copyInto(rArray);
            vector.copyInto(rArray);
            vector.copyInto(rArray);
            vector.copyInto(rArray);
            vector.copyInto(rArray);
            vector.copyInto(rArray);
            vector.copyInto(rArray);
            vector.copyInto(rArray);
            vector.copyInto(rArray);
        }
    
public voidtestVectorElementAt()

        int element;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            element = vector.elementAt(50);
            element = vector.elementAt(50);
            element = vector.elementAt(50);
            element = vector.elementAt(50);
            element = vector.elementAt(50);
            element = vector.elementAt(50);
            element = vector.elementAt(50);
            element = vector.elementAt(50);
            element = vector.elementAt(50);
            element = vector.elementAt(50);
        }
    
public voidtestVectorElements()

        Enumeration<Integer> elements;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            elements = vector.elements();
            elements = vector.elements();
            elements = vector.elements();
            elements = vector.elements();
            elements = vector.elements();
            elements = vector.elements();
            elements = vector.elements();
            elements = vector.elements();
            elements = vector.elements();
            elements = vector.elements();
        }
    
public voidtestVectorFirstElement()

        int element;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            element = vector.firstElement();
            element = vector.firstElement();
            element = vector.firstElement();
            element = vector.firstElement();
            element = vector.firstElement();
            element = vector.firstElement();
            element = vector.firstElement();
            element = vector.firstElement();
            element = vector.firstElement();
            element = vector.firstElement();
        }
    
public voidtestVectorGet()

        int element;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            element = vector.get(i);
            element = vector.get(i);
            element = vector.get(i);
            element = vector.get(i);
            element = vector.get(i);
            element = vector.get(i);
            element = vector.get(i);
            element = vector.get(i);
            element = vector.get(i);
            element = vector.get(i);
        }

    
public voidtestVectorHashcode()

        int element;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            element = vector.hashCode();
            element = vector.hashCode();
            element = vector.hashCode();
            element = vector.hashCode();
            element = vector.hashCode();
            element = vector.hashCode();
            element = vector.hashCode();
            element = vector.hashCode();
            element = vector.hashCode();
            element = vector.hashCode();
        }
    
public voidtestVectorIndexOf()

        int index, value = 0;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            index = vector.indexOf(value);
            index = vector.indexOf(value);
            index = vector.indexOf(value);
            index = vector.indexOf(value);
            index = vector.indexOf(value);
            index = vector.indexOf(value);
            index = vector.indexOf(value);
            index = vector.indexOf(value);
            index = vector.indexOf(value);
            index = vector.indexOf(value);
        }
    
public voidtestVectorInsertElementAt()

        Vector<String> vector = mStrVector;
        String string = mTestString;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            vector.insertElementAt(string, i);
            vector.insertElementAt(string, i);
            vector.insertElementAt(string, i);
            vector.insertElementAt(string, i);
            vector.insertElementAt(string, i);
            vector.insertElementAt(string, i);
            vector.insertElementAt(string, i);
            vector.insertElementAt(string, i);
            vector.insertElementAt(string, i);
            vector.insertElementAt(string, i);
        }
    
public voidtestVectorIsEmpty()

        boolean flag;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            flag = vector.isEmpty();
            flag = vector.isEmpty();
            flag = vector.isEmpty();
            flag = vector.isEmpty();
            flag = vector.isEmpty();
            flag = vector.isEmpty();
            flag = vector.isEmpty();
            flag = vector.isEmpty();
            flag = vector.isEmpty();
            flag = vector.isEmpty();
        }
    
public voidtestVectorLastElement()

        int element;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            element = vector.lastElement();
            element = vector.lastElement();
            element = vector.lastElement();
            element = vector.lastElement();
            element = vector.lastElement();
            element = vector.lastElement();
            element = vector.lastElement();
            element = vector.lastElement();
            element = vector.lastElement();
            element = vector.lastElement();
        }
    
public voidtestVectorLastIndexOf()

        int index, value = 0;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            index = vector.lastIndexOf(value);
            index = vector.lastIndexOf(value);
            index = vector.lastIndexOf(value);
            index = vector.lastIndexOf(value);
            index = vector.lastIndexOf(value);
            index = vector.lastIndexOf(value);
            index = vector.lastIndexOf(value);
            index = vector.lastIndexOf(value);
            index = vector.lastIndexOf(value);
            index = vector.lastIndexOf(value);
        }
    
public voidtestVectorRemove()

        int index, value = 0;
        Vector<Integer> vector = new Vector(mVector);
        for (int i = 10; i > 0; i--) {
            index = vector.remove(value);
            index = vector.remove(value);
            index = vector.remove(value);
            index = vector.remove(value);
            index = vector.remove(value);
            index = vector.remove(value);
            index = vector.remove(value);
            index = vector.remove(value);
            index = vector.remove(value);
            index = vector.remove(value);
        }
    
public voidtestVectorRemoveElement()

        Vector<Integer> vector = new Vector(mVector);
        for (int i = 10; i > 0; i--) {
            vector.removeElement(i);
            vector.removeElement(i);
            vector.removeElement(i);
            vector.removeElement(i);
            vector.removeElement(i);
            vector.removeElement(i);
            vector.removeElement(i);
            vector.removeElement(i);
            vector.removeElement(i);
            vector.removeElement(i);
        }
    
public voidtestVectorSet()

        Vector<Integer> vector = mVector;
        int pos = 5, value = 0;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            vector.set(pos, value);
            vector.set(pos, value);
            vector.set(pos, value);
            vector.set(pos, value);
            vector.set(pos, value);
            vector.set(pos, value);
            vector.set(pos, value);
            vector.set(pos, value);
            vector.set(pos, value);
            vector.set(pos, value);
        }
    
public voidtestVectorSetElementAt()

        Vector<Integer> vector = mVector;
        int value1 = 500, value2 = 50;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            vector.setElementAt(value1, value2);
            vector.setElementAt(value1, value2);
            vector.setElementAt(value1, value2);
            vector.setElementAt(value1, value2);
            vector.setElementAt(value1, value2);
            vector.setElementAt(value1, value2);
            vector.setElementAt(value1, value2);
            vector.setElementAt(value1, value2);
            vector.setElementAt(value1, value2);
            vector.setElementAt(value1, value2);
        }
    
public voidtestVectorSize()

        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            int mLen;
            mLen = vector.size();
            mLen = vector.size();
            mLen = vector.size();
            mLen = vector.size();
            mLen = vector.size();
            mLen = vector.size();
            mLen = vector.size();
            mLen = vector.size();
            mLen = vector.size();
            mLen = vector.size();
        }
    
public voidtestVectorToArray()

        Object array;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            array = vector.toArray();
            array = vector.toArray();
            array = vector.toArray();
            array = vector.toArray();
            array = vector.toArray();
            array = vector.toArray();
            array = vector.toArray();
            array = vector.toArray();
            array = vector.toArray();
            array = vector.toArray();
        }
    
public voidtestVectorToArray1()

        Integer[] rArray = new Integer[100];
        Integer[] array;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            array = vector.toArray(rArray);
            array = vector.toArray(rArray);
            array = vector.toArray(rArray);
            array = vector.toArray(rArray);
            array = vector.toArray(rArray);
            array = vector.toArray(rArray);
            array = vector.toArray(rArray);
            array = vector.toArray(rArray);
            array = vector.toArray(rArray);
            array = vector.toArray(rArray);
        }
    
public voidtestVectorToString()

        String str;
        Vector<Integer> vector = mVector;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            str = vector.toString();
            str = vector.toString();
            str = vector.toString();
            str = vector.toString();
            str = vector.toString();
            str = vector.toString();
            str = vector.toString();
            str = vector.toString();
            str = vector.toString();
            str = vector.toString();
        }