Lab 7: Benchmarking Continued
Overview
In this assignment, you incorporate feedback on your previous lab submission from your instructor (if available), and do more thorough asymptotic time complexity analysis. You will then generate plots of your benchmarking results and compare them with your time complexity analysis.
In addition to incorporating feedback from your instructor, if available, modify your program to
- Support named command line arguments
- Generate a plot of the benchmarking results
- Save the plot to a .png image
Video introduction for the lab
Assignment
Asympototic Time Complexity Analysis
Create a Word document and provide Big-O analysis for the following operations:
addToFront
on thejava.util.ArrayList
implementationaddToFront
on thejava.util.LinkedList
implementationindexedContains
on thedatastructures.ArrayList
implementationindexedContains
on thedatastructures.LinkedList
implementationindexedContains
on thedatastructures.LinkedListTurbo
implementation
You may need to study the code in the datastructures
classes
in order to do this analysis. Be sure to justify your reasoning.
Named Command Line Arguments
By supporting named command line arguments, you can place the arguments in any order. Your program must use the following names:
implementation
— the data structure to be benchmarkedoperation
— the operation to be benchmarkedstartSize
— the size of the largest list to be benchmarkeddivisor
— the divsor used to decrease the list size for additional benchmarksnumberOfSamples
— the total number of benchmark runsoutput
— location to save the plot image
Application.Parameters
class documentation
for how to access named parameters. The method you need to call returns a reference to a
Map<String, String>
.
You should find the get(String)
method useful.
When named command line arguments are supported, your program can be called as follows:
java -jar lab7username.jar --output=plots/containsLL.png --implementation=java.util.LinkedList --startSize=10000000 --operation=contains --numberOfSamples=7 --divisor=5
Ploting Benchmarking Results
Generate a benchmark chart for each of the scenarios above, and save each graph
as a .png image in a folder called plots
in the project folder. The images should
be named:
addToFrontAL.png
addToFrontLL.png
indexedContainsAL.png
indexedContainsLL.png
indexedContainsLLT.png
Generating line graphs is surprisingly easy in JavaFX. JavaFX Line Charts provides nice example code for how to generate these graphs.
Saving the Graph to a PNG
Once the graph has been added to your scene, you can save it to a file. The following code shows how:
WritableImage image = scene.snapshot(null);
File file = new File(filename);
ImageIO.write(SwingFXUtils.fromFXImage(image, null), "PNG", file);
lineChart.setAnimated(false);
before calling
lineChart.setTitle();
. You should also call
lineChart.applyCss();
and
lineChart.layout();
after the chart has been added to the scene
and after all of the data has been added to the line chart.
Big-O and Benchmarking Comparison
Add these charts to your Word document. Discuss how your Big-O analysis compares with the benchmarking results.
Acknowledgement
This laboratory assignment, developed by Dr. Chris Taylor.