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

TreeSetTest

public class TreeSetTest extends android.test.PerformanceTestBase
Implements basic performance test functionality for java.util.TreeSet

Fields Summary
public static final int
ITERATIONS
public static TreeSet
sSet
Constructors Summary
Methods Summary
protected voidsetUp()


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

        intermediates.setInternalIterations(ITERATIONS);
        return 0;
    
public voidtestTreeSetAdd()
Tests performance for the java.util.TreeSet method Add(Object arg 0)

        TreeSet<Integer> set = new TreeSet();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            set.add(i);
            set.add(i);
            set.add(i);
            set.add(i);
            set.add(i);
            set.add(i);
            set.add(i);
            set.add(i);
            set.add(i);
            set.add(i);
        }
    
public voidtestTreeSetClone()
Tests performance for the java.util.TreeSet method - clone()

        Object obj;
        TreeSet<Integer> set = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            obj = set.clone();
            obj = set.clone();
            obj = set.clone();
            obj = set.clone();
            obj = set.clone();
            obj = set.clone();
            obj = set.clone();
            obj = set.clone();
            obj = set.clone();
            obj = set.clone();
        }
    
public voidtestTreeSetComparator()
Tests performance for the java.util.TreeSet method - comparator()

        Comparator comparator;
        TreeSet<Integer> set = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            comparator = set.comparator();
            comparator = set.comparator();
            comparator = set.comparator();
            comparator = set.comparator();
            comparator = set.comparator();
            comparator = set.comparator();
            comparator = set.comparator();
            comparator = set.comparator();
            comparator = set.comparator();
        }
    
public voidtestTreeSetContains()
Tests performance of the java.util.TreeSet method- contains(Object arg0)

        Integer index = new Integer(500);
        boolean flag;
        TreeSet<Integer> set = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = set.contains(index);
            flag = set.contains(index);
            flag = set.contains(index);
            flag = set.contains(index);
            flag = set.contains(index);
            flag = set.contains(index);
            flag = set.contains(index);
            flag = set.contains(index);
            flag = set.contains(index);
        }
    
public voidtestTreeSetFirst()
Tests performance for the java.util.TreeSet method - first()

        int value;
        TreeSet<Integer> set = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            value = set.first();
            value = set.first();
            value = set.first();
            value = set.first();
            value = set.first();
            value = set.first();
            value = set.first();
            value = set.first();
            value = set.first();
        }
    
public voidtestTreeSetHeadSet()
Tests performance of the java.util.TreeSet method- headSet(Integer arg0)

        Integer value = new Integer(100);
        SortedSet set;
        TreeSet<Integer> tSet = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            set = tSet.headSet(value);
            set = tSet.headSet(value);
            set = tSet.headSet(value);
            set = tSet.headSet(value);
            set = tSet.headSet(value);
            set = tSet.headSet(value);
            set = tSet.headSet(value);
            set = tSet.headSet(value);
            set = tSet.headSet(value);
            set = tSet.headSet(value);
        }
    
public voidtestTreeSetIsEmpty()
Tests performance for the java.util.TreeSet method - isEmpty()

        boolean flag;
        TreeSet<Integer> tSet = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = tSet.isEmpty();
            flag = tSet.isEmpty();
            flag = tSet.isEmpty();
            flag = tSet.isEmpty();
            flag = tSet.isEmpty();
            flag = tSet.isEmpty();
            flag = tSet.isEmpty();
            flag = tSet.isEmpty();
            flag = tSet.isEmpty();
            flag = tSet.isEmpty();
        }
    
public voidtestTreeSetIterator()
Tests performance for the java.util.TreeSet method - iterator()

        Iterator iterator;
        TreeSet<Integer> set = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            iterator = set.iterator();
            iterator = set.iterator();
            iterator = set.iterator();
            iterator = set.iterator();
            iterator = set.iterator();
            iterator = set.iterator();
            iterator = set.iterator();
            iterator = set.iterator();
            iterator = set.iterator();
        }
    
public voidtestTreeSetLast()
Tests performance for the java.util.TreeSet method - last()

        int value;
        TreeSet<Integer> set = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            value = set.last();
            value = set.last();
            value = set.last();
            value = set.last();
            value = set.last();
            value = set.last();
            value = set.last();
            value = set.last();
            value = set.last();
        }
    
public voidtestTreeSetRemove()
Tests performance of the java.util.TreeSet method - remove(Object arg0)

        TreeSet<Integer> set = new TreeSet(sSet);
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            set.remove(i);
            set.remove(i);
            set.remove(i);
            set.remove(i);
            set.remove(i);
            set.remove(i);
            set.remove(i);
            set.remove(i);
            set.remove(i);
            set.remove(i);
        }
    
public voidtestTreeSetSize()
Tests performance for the java.util.TreeSet method - size()

        int value;
        TreeSet<Integer> set = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            value = set.size();
            value = set.size();
            value = set.size();
            value = set.size();
            value = set.size();
            value = set.size();
            value = set.size();
            value = set.size();
            value = set.size();
        }
    
public voidtestTreeSetSubSet()
Tests performance of subSet(Integer arg0, Integer arg1) - TreeSet

        Integer value = new Integer(400);
        Integer nInt = new Integer(500);
        SortedSet set;
        TreeSet<Integer> tSet = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            set = tSet.subSet(value, nInt);
            set = tSet.subSet(value, nInt);
            set = tSet.subSet(value, nInt);
            set = tSet.subSet(value, nInt);
            set = tSet.subSet(value, nInt);
            set = tSet.subSet(value, nInt);
            set = tSet.subSet(value, nInt);
            set = tSet.subSet(value, nInt);
            set = tSet.subSet(value, nInt);
            set = tSet.subSet(value, nInt);

        }

    
public voidtestTreeSetTailSet()
Tests performance of tailSet(Integer arg0) - TreeSet

        Integer value = new Integer(900);
        SortedSet set;
        TreeSet<Integer> tSet = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            set = tSet.tailSet(value);
            set = tSet.tailSet(value);
            set = tSet.tailSet(value);
            set = tSet.tailSet(value);
            set = tSet.tailSet(value);
            set = tSet.tailSet(value);
            set = tSet.tailSet(value);
            set = tSet.tailSet(value);
            set = tSet.tailSet(value);
            set = tSet.tailSet(value);
        }