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

HashtableTest

public class HashtableTest extends android.test.PerformanceTestBase
Implements basic performance test functionality for java.util.Hashtable

Fields Summary
public static final int
ITERATIONS
public Hashtable
sTable
public String[]
sKeys
Constructors Summary
Methods Summary
protected voidsetUp()

        super.setUp();
        sTable = new Hashtable();
        sKeys = new String[ITERATIONS];
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            sKeys[i] = Integer.toString(i, 16);
            sTable.put(sKeys[i], i);
        }
    
public intstartPerformance(PerformanceTestCase.Intermediates intermediates)

        intermediates.setInternalIterations(ITERATIONS);
        return 0;
    
public voidtestHashtableClone()
clone() returns a Hashtable .. It should return Object as per the specification.

        Hashtable hashTable;
        Hashtable<String, Integer> hTable = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            hashTable = (Hashtable) hTable.clone();
            hashTable = (Hashtable) hTable.clone();
            hashTable = (Hashtable) hTable.clone();
            hashTable = (Hashtable) hTable.clone();
            hashTable = (Hashtable) hTable.clone();
            hashTable = (Hashtable) hTable.clone();
            hashTable = (Hashtable) hTable.clone();
            hashTable = (Hashtable) hTable.clone();
            hashTable = (Hashtable) hTable.clone();
            hashTable = (Hashtable) hTable.clone();
        }
    
public voidtestHashtableContains()

        Hashtable<String, Integer> hTable = sTable;
        boolean flag;

        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = hTable.contains(i);
            flag = hTable.contains(i);
            flag = hTable.contains(i);
            flag = hTable.contains(i);
            flag = hTable.contains(i);
            flag = hTable.contains(i);
            flag = hTable.contains(i);
            flag = hTable.contains(i);
            flag = hTable.contains(i);
            flag = hTable.contains(i);
        }
    
public voidtestHashtableContainsKey()

        Hashtable<String, Integer> hTable = sTable;
        boolean flag;

        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = hTable.containsKey(i);
            flag = hTable.containsKey(i);
            flag = hTable.containsKey(i);
            flag = hTable.containsKey(i);
            flag = hTable.containsKey(i);
            flag = hTable.containsKey(i);
            flag = hTable.containsKey(i);
            flag = hTable.containsKey(i);
            flag = hTable.containsKey(i);
            flag = hTable.containsKey(i);
        }
    
public voidtestHashtableContainsValue()

        boolean flag;
        Hashtable<String, Integer> hTable = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = hTable.containsValue(i);
            flag = hTable.containsValue(i);
            flag = hTable.containsValue(i);
            flag = hTable.containsValue(i);
            flag = hTable.containsValue(i);
            flag = hTable.containsValue(i);
            flag = hTable.containsValue(i);
            flag = hTable.containsValue(i);
            flag = hTable.containsValue(i);
            flag = hTable.containsValue(i);
        }
    
public voidtestHashtableElements()

        Hashtable<String, Integer> hTable = sTable;
        Enumeration<Integer> elements;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            elements = hTable.elements();
            elements = hTable.elements();
            elements = hTable.elements();
            elements = hTable.elements();
            elements = hTable.elements();
            elements = hTable.elements();
            elements = hTable.elements();
            elements = hTable.elements();
            elements = hTable.elements();
            elements = hTable.elements();
        }
    
public voidtestHashtableEntrySet()

        Set keyset;
        Hashtable<String, Integer> hTable = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            keyset = hTable.entrySet();
            keyset = hTable.entrySet();
            keyset = hTable.entrySet();
            keyset = hTable.entrySet();
            keyset = hTable.entrySet();
            keyset = hTable.entrySet();
            keyset = hTable.entrySet();
            keyset = hTable.entrySet();
            keyset = hTable.entrySet();
            keyset = hTable.entrySet();
        }
    
public voidtestHashtableEquals()

        boolean flag;
        Hashtable<String, Integer> hTable = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = hTable.equals(hTable);
            flag = hTable.equals(hTable);
            flag = hTable.equals(hTable);
            flag = hTable.equals(hTable);
            flag = hTable.equals(hTable);
            flag = hTable.equals(hTable);
            flag = hTable.equals(hTable);
            flag = hTable.equals(hTable);
            flag = hTable.equals(hTable);
            flag = hTable.equals(hTable);
        }
    
public voidtestHashtableGet()

        int value;
        String[] keys = sKeys;
        Hashtable<String, Integer> hTable = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            value = hTable.get(keys[i]);
            value = hTable.get(keys[i]);
            value = hTable.get(keys[i]);
            value = hTable.get(keys[i]);
            value = hTable.get(keys[i]);
            value = hTable.get(keys[i]);
            value = hTable.get(keys[i]);
            value = hTable.get(keys[i]);
            value = hTable.get(keys[i]);
            value = hTable.get(keys[i]);
        }
    
public voidtestHashtableHashCode()

        int index;
        Hashtable<String, Integer> hTable = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            index = hTable.hashCode();
            index = hTable.hashCode();
            index = hTable.hashCode();
            index = hTable.hashCode();
            index = hTable.hashCode();
            index = hTable.hashCode();
            index = hTable.hashCode();
            index = hTable.hashCode();
            index = hTable.hashCode();
            index = hTable.hashCode();
        }
    
public voidtestHashtableIsEmpty()

        Hashtable<String, Integer> hTable = sTable;
        boolean flag;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            flag = hTable.isEmpty();
            flag = hTable.isEmpty();
            flag = hTable.isEmpty();
            flag = hTable.isEmpty();
            flag = hTable.isEmpty();
            flag = hTable.isEmpty();
            flag = hTable.isEmpty();
            flag = hTable.isEmpty();
            flag = hTable.isEmpty();
            flag = hTable.isEmpty();
        }
    
public voidtestHashtableKeys()

        Hashtable<String, Integer> hTable = sTable;
        Enumeration<String> keys;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            keys = hTable.keys();
            keys = hTable.keys();
            keys = hTable.keys();
            keys = hTable.keys();
            keys = hTable.keys();
            keys = hTable.keys();
            keys = hTable.keys();
            keys = hTable.keys();
            keys = hTable.keys();
            keys = hTable.keys();
        }
    
public voidtestHashtablePut()

        Hashtable hTable = new Hashtable();
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            hTable.put(i, i);
            hTable.put(i, i);
            hTable.put(i, i);
            hTable.put(i, i);
            hTable.put(i, i);
            hTable.put(i, i);
            hTable.put(i, i);
            hTable.put(i, i);
            hTable.put(i, i);
            hTable.put(i, i);
        }
    
public voidtestHashtablePutAll()

        Hashtable<String, Integer> hTable = new Hashtable();
        Hashtable<String, Integer> hTable1 = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            hTable.putAll(hTable1);
            hTable.putAll(hTable1);
            hTable.putAll(hTable1);
            hTable.putAll(hTable1);
            hTable.putAll(hTable1);
            hTable.putAll(hTable1);
            hTable.putAll(hTable1);
            hTable.putAll(hTable1);
            hTable.putAll(hTable1);
            hTable.putAll(hTable1);
        }
    
public voidtestHashtableRemove()

        Hashtable<String, Integer> hTable = new Hashtable(sTable);
        String[] keys = sKeys;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            hTable.remove(keys[i]);
            hTable.remove(keys[i]);
            hTable.remove(keys[i]);
            hTable.remove(keys[i]);
            hTable.remove(keys[i]);
            hTable.remove(keys[i]);
            hTable.remove(keys[i]);
            hTable.remove(keys[i]);
            hTable.remove(keys[i]);
            hTable.remove(keys[i]);
        }
    
public voidtestHashtableSize()

        int len;
        Hashtable<String, Integer> hTable = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            len = hTable.size();
            len = hTable.size();
            len = hTable.size();
            len = hTable.size();
            len = hTable.size();
            len = hTable.size();
            len = hTable.size();
            len = hTable.size();
            len = hTable.size();
            len = hTable.size();
        }
    
public voidtestHashtableToString()

        String str;
        Hashtable<String, Integer> hTable = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            str = hTable.toString();
            str = hTable.toString();
            str = hTable.toString();
            str = hTable.toString();
            str = hTable.toString();
            str = hTable.toString();
            str = hTable.toString();
            str = hTable.toString();
            str = hTable.toString();
            str = hTable.toString();
        }
    
public voidtestHashtablekeyset()

        Set keyset;
        Hashtable<String, Integer> hTable = sTable;
        for (int i = ITERATIONS - 1; i >= 0; i--) {
            keyset = hTable.keySet();
            keyset = hTable.keySet();
            keyset = hTable.keySet();
            keyset = hTable.keySet();
            keyset = hTable.keySet();
            keyset = hTable.keySet();
            keyset = hTable.keySet();
            keyset = hTable.keySet();
            keyset = hTable.keySet();
            keyset = hTable.keySet();
        }