public class SetTesterMain
extends java.lang.Object
The data will be stored in four different data structures and the analysis will include measuring the time to complete three different common operations on different sized random and sorted data sets.
The data types each implement the SetTesterADT interface but have different underlying data structures and thus different performance when the problem size is large. Having each type implement a common interface will make it easier to run equivalent comparisons.
Modifier and Type | Field and Description |
---|---|
private int |
numOfDisplayLevels
The number of levels to display of the BSTree structures
|
private int |
numOfTrials
Number of trials to run for each operation
|
private java.util.List<java.lang.Integer> |
originalDataList
Data read from a file and used for evaluation timing trials.
|
private int |
rebalanceThreshold
Rebalance threshold for binary search tree with rebalance
|
Constructor and Description |
---|
SetTesterMain(java.lang.String dataFile,
int numOfTrials,
int rebalanceThreshold,
int numOfDisplayLevels)
Evaluator constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
displayResultTable(boolean sorted,
Stats listResult,
Stats bsTreeResult,
Stats bsTreeBResult,
Stats rbTreeResult,
int rebalanceThreshold)
Display the evaluation results.
|
Stats |
evaluateAll(SetTesterADT<java.lang.Integer> dataStructure)
The evaluation method runs the trials and stores the results for
these operations:
the time to build the Integer data structure (add all items)
the time to search for individual items in the data structure
the time to search for all items within a given range of values
The number of trials has been stored as a data field.
|
long |
evaluateBuild(SetTesterADT<java.lang.Integer> tester)
Evaluate the building tree process.
|
long |
evaluateContainsSearch(SetTesterADT<java.lang.Integer> ds)
Run a single trial that times and searches for each item in the original
data listing.
|
long |
evaluateRangeSearch(SetTesterADT<java.lang.Integer> ds)
Time how long it take to search for items within a given range
from each element.
|
static void |
main(java.lang.String[] args)
Main method.
|
void |
runEvaluation(boolean sortData)
Run the evaluation trials and display result tables.
|
private java.util.List<java.lang.Integer> originalDataList
private int numOfTrials
private int rebalanceThreshold
private int numOfDisplayLevels
public SetTesterMain(java.lang.String dataFile, int numOfTrials, int rebalanceThreshold, int numOfDisplayLevels)
dataFile
- data file name.numOfTrials
- number of trials for each evaluation.rebalanceThreshold
- rebalance threshold for the binary search tree
with rebalance.numOfDisplayLevels
- The number of levels to display for BSTreepublic static void main(java.lang.String[] args)
Main method. Every application needs one. Command-line arguments are required.
For example:
java SetTesterMain random_1000.txt 10 2 3
args
- filename numTrials rebalanceThreshold numLevelspublic void runEvaluation(boolean sortData)
sortData
- if true, sort the data before evaluation.public Stats evaluateAll(SetTesterADT<java.lang.Integer> dataStructure)
dataStructure
- the data structure to evaluate.public long evaluateBuild(SetTesterADT<java.lang.Integer> tester)
tester
- the data structure to evaluatepublic long evaluateContainsSearch(SetTesterADT<java.lang.Integer> ds)
ds
- the data structure filled with data to testjava.lang.RuntimeException
- if a data item is not found in the SetTesterpublic long evaluateRangeSearch(SetTesterADT<java.lang.Integer> ds)
ds
- the data structure to evaluatepublic void displayResultTable(boolean sorted, Stats listResult, Stats bsTreeResult, Stats bsTreeBResult, Stats rbTreeResult, int rebalanceThreshold)
sorted
- indicates if the data was sorted for these resultslistResult
- evaluate results of ListSetbsTreeResult
- evaluate results of bsTreebsTreeBResult
- evaluate results of bsTreeBrbTreeResult
- evaluate results of rbTreerebalanceThreshold
- the integer indicating when to rebalance
the BSTreeB data structure