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

HashSetTest

public class HashSetTest extends android.test.PerformanceTestBase
Implements basic performance test functionality for HashSets

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


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

        intermediates.setInternalIterations(ITERATIONS);
        return 0;
    
public voidtestHashSetAdd()
Tests performance for the HashSet method Add(Object arg 0)

        HashSet set = new HashSet();
        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 voidtestHashSetClone()
Tests performance for the HashSet method clone()

        HashSet hSet = sSet;
        Object set;
        for (int i = ITERATIONS - 1; i > 0; i--) {
            set = hSet.clone();
            set = hSet.clone();
            set = hSet.clone();
            set = hSet.clone();
            set = hSet.clone();
            set = hSet.clone();
            set = hSet.clone();
            set = hSet.clone();
            set = hSet.clone();
            set = hSet.clone();
        }
    
public voidtestHashSetContains()
Tests performance of HashSet method contains(Object arg 0)

        Integer index = new Integer(500);
        boolean flag;
        HashSet 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 voidtestHashSetIsEmpty()
Tests performance for the HashSet method isEmpty(Object arg 0)

        HashSet set = sSet;
        boolean flag;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = set.isEmpty();
            flag = set.isEmpty();
            flag = set.isEmpty();
            flag = set.isEmpty();
            flag = set.isEmpty();
            flag = set.isEmpty();
            flag = set.isEmpty();
            flag = set.isEmpty();
            flag = set.isEmpty();
            flag = set.isEmpty();
        }
    
public voidtestHashSetIterator()
Tests performance of the HashSet method -iterator()

        Iterator iterator;
        HashSet 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 voidtestHashSetRemove()
Tests performance for the HashSet method Remove(Object arg 0)

        HashSet set = new HashSet(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 voidtestHashSetSize()
Tests performance of HashSet method size()

        int num;
        HashSet set = sSet;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            num = set.size();
            num = set.size();
            num = set.size();
            num = set.size();
            num = set.size();
            num = set.size();
            num = set.size();
            num = set.size();
            num = set.size();
        }