FileDocCategorySizeDatePackage
SetPerformance.javaAPI DocExample4110Mon Apr 06 18:10:26 BST 1998c08.newcollections

SetPerformance

public class SetPerformance extends Object

Fields Summary
private static final int
REPS
private static Tester[]
tests
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    // Small:
    test(new TreeSet(), 10);
    test(new HashSet(), 10);
    // Medium:
    test(new TreeSet(), 100);
    test(new HashSet(), 100);
    // Large:
    test(new HashSet(), 1000);
    test(new TreeSet(), 1000);
  
public static voidtest(java.util.Set s, int size)

         
    // A trick to print out the class name:
    System.out.println("Testing " + 
      s.getClass().getName() + " size " + size);
    Collection1.fill(s, size);
    for(int i = 0; i < tests.length; i++) {
      System.out.print(tests[i].name);
      long t1 = System.currentTimeMillis();
      tests[i].test(s, size);
      long t2 = System.currentTimeMillis();
      System.out.println(": " + 
        ((double)(t2 - t1)/(double)size));
    }