diff --git a/src/main/java/io/github/compilerstuck/Control/MainController.java b/src/main/java/io/github/compilerstuck/Control/MainController.java index f8caaf5..c652cb0 100644 --- a/src/main/java/io/github/compilerstuck/Control/MainController.java +++ b/src/main/java/io/github/compilerstuck/Control/MainController.java @@ -7,6 +7,7 @@ import io.github.compilerstuck.Sound.Sound; import io.github.compilerstuck.Visual.Bars; import io.github.compilerstuck.Visual.Gradient.ColorGradient; +import javafx.util.Pair; import io.github.compilerstuck.Visual.Visualization; import processing.core.PApplet; @@ -30,6 +31,7 @@ public class MainController extends PApplet { private final ArrayList swaps = new ArrayList<>(); private final ArrayList writesMain = new ArrayList<>(); private final ArrayList writesAux = new ArrayList<>(); + private final ArrayList timestamps = new ArrayList<>(); private static boolean start = false; private static boolean running = false; @@ -147,6 +149,9 @@ public void draw() { settings.setProgressBar(100); settings.setEnableInputs(true); settings.setEnableCancelButton(false); + + printTimestampsToConsole(); + } else if (running) { visualization.update(); arrayController.update(); @@ -175,21 +180,18 @@ public void draw() { private void startAlgorithmThread() { new Thread(() -> { + + int startTime = (int) (System.currentTimeMillis() / 1000L); + for (SortingAlgorithm algorithm : algorithms) { if (!SortingAlgorithm.isRun()) { break; } -// if (alg.alternativeSize != arrayController.getLength()) { -// sound.mute(true); -// colorGradient.updateGradient(alg.alternativeSize); -// arrayController.resize(alg.alternativeSize); -// -// delay(1000); -// sound.mute(false); -// } + sound.mute(true); sound.mute(false); + timestamps.add((int) (System.currentTimeMillis() / 1000L) - startTime); arrayController.shuffle(); if (!SortingAlgorithm.isRun()) { @@ -238,6 +240,16 @@ public static void shutdown(){ processing.exit(); } + public void printTimestampsToConsole() { + System.out.println("\nTimestamps:"); + for (int i = 0; i < algorithms.size(); i++) { + int minutes = timestamps.get(i) / 60; + int seconds = timestamps.get(i) % 60; + String time = String.format("%02d:%02d", minutes, seconds); + System.out.println(time + " " + algorithms.get(i).getName()); + } + } + private void printResults() { textSize((int) (20. / 1280 * width)); background(15); diff --git a/src/main/java/io/github/compilerstuck/SortingAlgorithms/GravitySort.java b/src/main/java/io/github/compilerstuck/SortingAlgorithms/GravitySort.java index 7bf18b9..d3b1a4a 100644 --- a/src/main/java/io/github/compilerstuck/SortingAlgorithms/GravitySort.java +++ b/src/main/java/io/github/compilerstuck/SortingAlgorithms/GravitySort.java @@ -7,7 +7,7 @@ public class GravitySort extends SortingAlgorithm { public GravitySort(ArrayController arrayController) { super(arrayController); - this.name = "Gravity (Bead) Sort"; + this.name = "Gravity Sort"; alternativeSize = arrayController.getLength(); delayTime = 2; } diff --git a/src/main/java/io/github/compilerstuck/SortingAlgorithms/QuickSortMiddlePivot.java b/src/main/java/io/github/compilerstuck/SortingAlgorithms/QuickSortMiddlePivot.java index 7739410..b6c8828 100644 --- a/src/main/java/io/github/compilerstuck/SortingAlgorithms/QuickSortMiddlePivot.java +++ b/src/main/java/io/github/compilerstuck/SortingAlgorithms/QuickSortMiddlePivot.java @@ -8,7 +8,7 @@ public class QuickSortMiddlePivot extends SortingAlgorithm { public QuickSortMiddlePivot(ArrayController arrayController) { super(arrayController); - this.name = "Quick Sort (Pivot Middle)"; + this.name = "Quick Sort (Middle Pivot)"; alternativeSize = arrayController.getLength(); } diff --git a/src/main/java/io/github/compilerstuck/SortingAlgorithms/RadixLSDSortBase10.java b/src/main/java/io/github/compilerstuck/SortingAlgorithms/RadixLSDSortBase10.java index 9358dad..a039b4f 100644 --- a/src/main/java/io/github/compilerstuck/SortingAlgorithms/RadixLSDSortBase10.java +++ b/src/main/java/io/github/compilerstuck/SortingAlgorithms/RadixLSDSortBase10.java @@ -12,14 +12,14 @@ public class RadixLSDSortBase10 extends SortingAlgorithm { public RadixLSDSortBase10(ArrayController arrayController) { super(arrayController); - this.name = "Radix (LSD) Sort (Base " + RADIX + ")"; + this.name = "Radix Sort (LSD) (Base " + RADIX + ")"; alternativeSize = arrayController.getLength(); } public RadixLSDSortBase10(ArrayController arrayController, int radix_base) { super(arrayController); RADIX = radix_base; - this.name = "Radix (LSD) Sort (Base " + RADIX + ")"; + this.name = "Radix Sort (LSD) (Base " + RADIX + ")"; }