rendered paste bodypublic class BenchmarkSort{ private Sort sort = new Sort(); private Timer t = new Timer(); public static void main(String [] args) { BenchmarkSort bm = new BenchmarkSort(); bm.differentSorts(100, 1); bm.differentSorts(1000, 1); bm.differentSorts(10000, 1); bm.differentSorts(100000, 1); bm.differentSorts(1000000, 1); bm.differentSorts(100, 2); bm.differentSorts(1000, 2); bm.differentSorts(10000, 2); bm.differentSorts(100000, 2); bm.differentSorts(1000000, 2); bm.differentSorts(100, 3); bm.differentSorts(1000, 3); bm.differentSorts(10000, 3); bm.differentSorts(100000, 3); bm.differentSorts(1000000, 3); } public BenchmarkSort() { } public void differentSorts(int size, int type) { int[] a = new int[size]; String arrayType = ""; if (type == 1) { arrayType = "Random"; a = sort.generateRandomArray(size); } else if (type == 2) { arrayType = "Sorted"; a = sort.generateSortedArray(size); } else if (type == 3) { arrayType = "Sorted backwards"; a = sort.generateSortedBackwardsArray(size); } System.out.println("\n\n------------------------------------"); System.out.println(arrayType + " array with " + size + " elements"); System.out.println("------------------------------------"); int[] b = new int[a.length]; b = a.clone(); System.out.print("Quick-Sort with random pivot: "); t.reset(); t.start(); sort.quickSort(b, 1); t.stop(); System.out.println(t.duration() + " ms"); b = a.clone(); System.out.print("Quick-Sort with median pivot: "); t.reset(); t.start(); sort.quickSort(b, 2); t.stop(); System.out.println(t.duration() + " ms"); b = a.clone(); System.out.print("Insertion Sort: "); t.reset(); t.start(); sort.quickSort(b, 2); t.stop(); System.out.println(t.duration() + " ms"); /* b = (int[])a.clone(); System.out.print("Insertion pivot: "); t.reset(); t.start(); sort.quickSort(b, 1); t.stop(); */ } }