timertests
Class TimerTests

java.lang.Object
  extended by timertests.TimerTests

 class TimerTests
extends java.lang.Object


Field Summary
protected  java.util.ArrayList<stresstests.algorithms.ASortAlgo<stresstests.datasets.City>> algorithms
          an ArrayList of algorithms to run
protected  java.util.Comparator<stresstests.datasets.City> byLatitude
          compare cities by their latitude
protected  java.util.Comparator<stresstests.datasets.City> byName
          compare cities by the name of the city
protected  java.util.Comparator<stresstests.datasets.City> byZip
          compare cities by the zip code
protected  java.util.ArrayList<java.util.Comparator<stresstests.datasets.City>> comparators
          create a list of all Comparators
protected  java.util.ArrayList<java.lang.String> compNames
          create a corresponding list of all Comparator names
protected  long endTime
          the ending time for the sorting test
protected  long startTime
          the starting time for the sorting test
protected  TestData testdata
          The collection of data sets used in the tests
 
Constructor Summary
protected TimerTests()
          The constructor only creates the three known Comparators
 
Method Summary
protected  void allAlgos(java.util.ArrayList<java.util.Comparator<stresstests.datasets.City>> comparators)
          Add to the algorithms each of the known algorithm with each of the given Comparators
protected  java.util.ArrayList<Result> allTests()
          Run the tests of all selected algorithms with all selected comparators on all selected datasets and save the results
protected  boolean isSorted(stresstests.interfaces.Traversal<stresstests.datasets.City> tr, java.util.Comparator<stresstests.datasets.City> comp)
          Is the data generated by the given traversal sorted by comparator?
protected  boolean isSortedAcc(stresstests.interfaces.Traversal<stresstests.datasets.City> tr, java.util.Comparator<stresstests.datasets.City> comp, stresstests.datasets.City acc)
          Is the data generated by the given traversal sorted by comparator? and greater than or equal to the previous largest value?
static void main(java.lang.String[] argv)
          Self Test
protected  void makeAlgos(java.util.Comparator<stresstests.datasets.City> comp)
          Add to the ArrayList of ASortAlgos each available algorithm with the given Comparator
protected  void makeComparators()
          Construct the ArrayList of all available Comparators
protected  Result runATest(stresstests.algorithms.ASortAlgo<stresstests.datasets.City> algo, DataSet<stresstests.datasets.City> dataset)
          Run one test of a given sorting algorithm with the given comparator and the desired size of data, random or sequentially selected
protected  void sampleTest()
          A sample test for this class
protected  java.util.ArrayList<java.lang.Integer> selectDataSets()
          Produce a list of indices selecting the datasets to use in the sorting tests
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

byName

protected java.util.Comparator<stresstests.datasets.City> byName
compare cities by the name of the city


byZip

protected java.util.Comparator<stresstests.datasets.City> byZip
compare cities by the zip code


byLatitude

protected java.util.Comparator<stresstests.datasets.City> byLatitude
compare cities by their latitude


comparators

protected java.util.ArrayList<java.util.Comparator<stresstests.datasets.City>> comparators
create a list of all Comparators


compNames

protected java.util.ArrayList<java.lang.String> compNames
create a corresponding list of all Comparator names


algorithms

protected java.util.ArrayList<stresstests.algorithms.ASortAlgo<stresstests.datasets.City>> algorithms
an ArrayList of algorithms to run


testdata

protected TestData testdata
The collection of data sets used in the tests


startTime

protected long startTime
the starting time for the sorting test


endTime

protected long endTime
the ending time for the sorting test

Constructor Detail

TimerTests

protected TimerTests()
The constructor only creates the three known Comparators

Method Detail

makeComparators

protected void makeComparators()
Construct the ArrayList of all available Comparators


makeAlgos

protected void makeAlgos(java.util.Comparator<stresstests.datasets.City> comp)
Add to the ArrayList of ASortAlgos each available algorithm with the given Comparator

Parameters:
comp - the Comparator used by these algorithms

allAlgos

protected void allAlgos(java.util.ArrayList<java.util.Comparator<stresstests.datasets.City>> comparators)
Add to the algorithms each of the known algorithm with each of the given Comparators

Parameters:
comparators -

selectDataSets

protected java.util.ArrayList<java.lang.Integer> selectDataSets()
Produce a list of indices selecting the datasets to use in the sorting tests

Returns:
a list of indices indicating which datasets should be sorted

allTests

protected java.util.ArrayList<Result> allTests()
Run the tests of all selected algorithms with all selected comparators on all selected datasets and save the results

Returns:
an ArrayList of Result data

runATest

protected Result runATest(stresstests.algorithms.ASortAlgo<stresstests.datasets.City> algo,
                          DataSet<stresstests.datasets.City> dataset)
Run one test of a given sorting algorithm with the given comparator and the desired size of data, random or sequentially selected

Parameters:
algo - the ASortAlgo algorithm with the chosen Comparator
dataset - the data to be sorted
Returns:
an instance of the Result reporting all relevant data

sampleTest

protected void sampleTest()
A sample test for this class


isSorted

protected boolean isSorted(stresstests.interfaces.Traversal<stresstests.datasets.City> tr,
                           java.util.Comparator<stresstests.datasets.City> comp)
Is the data generated by the given traversal sorted by comparator?

Parameters:
tr - the given Traversal that generates the data to be sorted
comp - the Comparator that determines the ordering
Returns:
true if the data is sorted

isSortedAcc

protected boolean isSortedAcc(stresstests.interfaces.Traversal<stresstests.datasets.City> tr,
                              java.util.Comparator<stresstests.datasets.City> comp,
                              stresstests.datasets.City acc)
Is the data generated by the given traversal sorted by comparator? and greater than or equal to the previous largest value?

Parameters:
tr - the given Traversal that generates the data to be sorted
comp - the Comparator that determines the ordering
acc - the last value seen traversing over the data
Returns:
true if the data is sorted

main

public static void main(java.lang.String[] argv)
Self Test