1616 */
1717package main ;
1818
19+ import algorithms .IntQuickSort ;
1920import utils .Operations ;
2021import algorithms .MinBinaryHeap ;
2122import algorithms .MinBinomialHeap ;
@@ -44,6 +45,7 @@ public class BenchmarkResultGUI {
4445 private int iterations ;
4546 private Operations [] operations ;
4647 private InputTypes sorting ;
48+ private int [] benchData ;
4749
4850 /**
4951 * Class for creating barchart window
@@ -58,6 +60,8 @@ public BenchmarkResultGUI(int inputLenght, int iterations, Operations[] operatio
5860 this .iterations = iterations ;
5961 this .operations = operations ;
6062 this .sorting = sorting ;
63+ //Create test data for bechmarks
64+ this .benchData = createTestData (iterations );
6165
6266 }
6367
@@ -84,9 +88,9 @@ public Scene run() {
8488 series3 .setName ("Fibonacci Heap" );
8589 ObservableList <Label > list = FXCollections .<Label >observableArrayList ();
8690
87- Benchmark benBinary = new Benchmark (new MinBinaryHeap (), this .iterations , this .inputLenght , this . sorting );
88- Benchmark benBinomial = new Benchmark (new MinBinomialHeap (), this .iterations , this .inputLenght , this . sorting );
89- Benchmark benFibonacci = new Benchmark (new MinFibonaciHeap (), this .iterations , this .inputLenght , this . sorting );
91+ Benchmark benBinary = new Benchmark (new MinBinaryHeap (), this .iterations , this .benchData );
92+ Benchmark benBinomial = new Benchmark (new MinBinomialHeap (), this .iterations , this .benchData );
93+ Benchmark benFibonacci = new Benchmark (new MinFibonaciHeap (), this .iterations , this .benchData );
9094
9195 for (Operations operation : operations ) {
9296
@@ -172,4 +176,25 @@ public Scene run() {
172176 return chartScene ;
173177 }
174178
179+ private int [] createTestData (int size ) {
180+
181+ int [] values = new int [size ];
182+
183+ for (int i = 0 ; i < size ; i ++) {
184+
185+ values [i ] = ((int ) ((System .nanoTime () % 10000 * 0.0001 ) * Integer .MAX_VALUE ));
186+ }
187+
188+ //sort generated data based on the instance varibale this.sorting
189+ if (this .sorting .equals (InputTypes .ASCENDING )) {
190+ values = IntQuickSort .quickSortAscend (values , 0 , size - 1 );
191+ }
192+ if (this .sorting .equals (InputTypes .DESCENDING )) {
193+ values = IntQuickSort .quickSortDescen (values , 0 , size - 1 );
194+
195+ }
196+
197+ return values ;
198+ }
199+
175200}
0 commit comments