From e6ab4f665649b8cbd765f850c0b463b1063933ed Mon Sep 17 00:00:00 2001 From: Daniel Langbein Date: Tue, 7 Jan 2025 17:32:18 +0000 Subject: [PATCH] benchmark: separate benchmarks --- README.md | 26 +- app/build.gradle.kts | 14 +- .../powersort/benchmark/JmhCgl.java | 31 ++ .../powersort/benchmark/JmhCompetition.java | 3 +- .../benchmark/{Main.java => CbmBase.java} | 9 +- .../powersort/benchmark/CbmCgl.java | 13 + .../powersort/benchmark/CbmCompetition.java | 13 + .../powersort/benchmark/Filter.java | 212 ++++---- .../uni_marburg/powersort/data/CglEnum.java | 33 ++ .../powersort/data/CompetitionEnum.java | 500 +++++++++++++++++ .../uni_marburg/powersort/data/DataEnum.java | 512 +----------------- .../powersort/data/IntegerSerializer.java | 6 +- 12 files changed, 746 insertions(+), 626 deletions(-) create mode 100644 app/src/jmh/java/de/uni_marburg/powersort/benchmark/JmhCgl.java rename app/src/main/java/de/uni_marburg/powersort/benchmark/{Main.java => CbmBase.java} (87%) create mode 100644 app/src/main/java/de/uni_marburg/powersort/benchmark/CbmCgl.java create mode 100644 app/src/main/java/de/uni_marburg/powersort/benchmark/CbmCompetition.java create mode 100644 app/src/main/java/de/uni_marburg/powersort/data/CglEnum.java create mode 100644 app/src/main/java/de/uni_marburg/powersort/data/CompetitionEnum.java diff --git a/README.md b/README.md index 165230d..e81cd12 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ Implementation of Powersort with the aim of integrating it into OpenJDK. Benchma * [Tasks](#tasks) * [Test Cases](#test-cases) * [Benchmark](#benchmark) + * [Custom](#custom) + * [JMH](#jmh) ## Setup @@ -86,7 +88,29 @@ Run the task "test": There are two different benchmarks. One is based on the JMH benchmark framework, the other one is a custom benchmark implementation. +### Custom + +Run custom benchmark: + +```shell +./gradlew runCbmCgl +./gradlew runCbmCompetition +``` + +### JMH + +Run JMH benchmark: + ```shell ./gradlew jmh -./gradlew runCustomBenchmark ``` + +IntelliJ plugin: + +The [JMH Java Microbenchmark Harness](https://plugins.jetbrains.com/plugin/7529-jmh-java-microbenchmark-harness) plugin allows running benchmarks from within the IDE in a similar way as JUnit test cases. This can be used for development but yields less accurate results. + +Further notes: + +- JHM: https://github.com/openjdk/jmh?tab=readme-ov-file#other-build-systems +- We use the JMH Gradle plugin: https://github.com/melix/jmh-gradle-plugin +- Sample JMH Gradle project: https://github.com/twoVersatile/jmhsample diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e61acfb..1628776 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -22,7 +22,6 @@ val latestJmhVersion = "1.37" dependencies { // Use JUnit Jupiter for testing. testImplementation(libs.junit.jupiter) - testRuntimeOnly("org.junit.platform:junit-platform-launcher") // Required to use the IntelliJ plugin "JMH Java Microbenchmark Harness". @@ -42,14 +41,21 @@ java { // It is not possible to rename it. // Thus, we remove it and add two custom named `JavaExec` tasks instead. tasks.getByName("run") { - enabled = false description = "This task has been disabled. It does nothing o.O" + enabled = false } -tasks.register("runCustomBenchmark") { +tasks.register("runCbmCgl") { + description = "Run Custom Benchmark (CBM) with Custom Generated Lists (CGL)" group = "application" classpath = sourceSets["main"].runtimeClasspath - mainClass = "de.uni_marburg.powersort.benchmark.Main" + mainClass = "de.uni_marburg.powersort.benchmark.CbmCgl" +} +tasks.register("runCbmCompetition") { + description = "Run Custom Benchmark (CBM) with Powersort competition lists" + group = "application" + classpath = sourceSets["main"].runtimeClasspath + mainClass = "de.uni_marburg.powersort.benchmark.CbmCompetition" } tasks.named("test") { diff --git a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/JmhCgl.java b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/JmhCgl.java new file mode 100644 index 0000000..ede8f4a --- /dev/null +++ b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/JmhCgl.java @@ -0,0 +1,31 @@ +package de.uni_marburg.powersort.benchmark; + +import de.uni_marburg.powersort.data.CglEnum; +import de.uni_marburg.powersort.data.DataEnum; +import de.uni_marburg.powersort.sort.SortEnum; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.State; + +/* + * Benchmark state parameters + * + * Quote from JMH: + * State objects naturally encapsulate the state on which benchmark is working on. + */ +@State(Scope.Benchmark) +public class JmhCgl extends JmhBase { + @Param() + CglEnum dataEnum; + @Param() + SortEnum sortEnum; + + @Override + DataEnum getDataEnum(){ + return dataEnum; + } + @Override + SortEnum getSortEnum(){ + return sortEnum; + } +} diff --git a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/JmhCompetition.java b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/JmhCompetition.java index 2fc07c6..f6b4cba 100644 --- a/app/src/jmh/java/de/uni_marburg/powersort/benchmark/JmhCompetition.java +++ b/app/src/jmh/java/de/uni_marburg/powersort/benchmark/JmhCompetition.java @@ -1,5 +1,6 @@ package de.uni_marburg.powersort.benchmark; +import de.uni_marburg.powersort.data.CompetitionEnum; import de.uni_marburg.powersort.data.DataEnum; import de.uni_marburg.powersort.sort.SortEnum; import org.openjdk.jmh.annotations.Param; @@ -15,7 +16,7 @@ import org.openjdk.jmh.annotations.State; @State(Scope.Benchmark) public class JmhCompetition extends JmhBase { @Param() - DataEnum dataEnum; + CompetitionEnum dataEnum; @Param() SortEnum sortEnum; diff --git a/app/src/main/java/de/uni_marburg/powersort/benchmark/Main.java b/app/src/main/java/de/uni_marburg/powersort/benchmark/CbmBase.java similarity index 87% rename from app/src/main/java/de/uni_marburg/powersort/benchmark/Main.java rename to app/src/main/java/de/uni_marburg/powersort/benchmark/CbmBase.java index 8eb858b..57172b4 100644 --- a/app/src/main/java/de/uni_marburg/powersort/benchmark/Main.java +++ b/app/src/main/java/de/uni_marburg/powersort/benchmark/CbmBase.java @@ -7,13 +7,10 @@ import de.uni_marburg.powersort.data.ObjectSupplier; import java.util.concurrent.TimeUnit; /** - * Custom benchmark. + * Custom Benchmark (CBM). */ -public class Main { - public static void main(final String[] args) { - final SortEnum[] sortImplementations = SortEnum.values(); - final DataEnum[] dataEnums = DataEnum.values(); - +public class CbmBase { + static void run(SortEnum[] sortImplementations, DataEnum[] dataEnums) { System.out.println(); for (DataEnum dataEnum : dataEnums) { ObjectSupplier objectSupplier = null; diff --git a/app/src/main/java/de/uni_marburg/powersort/benchmark/CbmCgl.java b/app/src/main/java/de/uni_marburg/powersort/benchmark/CbmCgl.java new file mode 100644 index 0000000..bc8ec7a --- /dev/null +++ b/app/src/main/java/de/uni_marburg/powersort/benchmark/CbmCgl.java @@ -0,0 +1,13 @@ +package de.uni_marburg.powersort.benchmark; + +import de.uni_marburg.powersort.data.CglEnum; +import de.uni_marburg.powersort.sort.SortEnum; + +public class CbmCgl { + public static void main(String[] args) { + CbmBase.run( + SortEnum.values(), + CglEnum.values() + ); + } +} diff --git a/app/src/main/java/de/uni_marburg/powersort/benchmark/CbmCompetition.java b/app/src/main/java/de/uni_marburg/powersort/benchmark/CbmCompetition.java new file mode 100644 index 0000000..03f4d6a --- /dev/null +++ b/app/src/main/java/de/uni_marburg/powersort/benchmark/CbmCompetition.java @@ -0,0 +1,13 @@ +package de.uni_marburg.powersort.benchmark; + +import de.uni_marburg.powersort.data.CompetitionEnum; +import de.uni_marburg.powersort.sort.SortEnum; + +public class CbmCompetition { + public static void main(String[] args) { + CbmBase.run( + SortEnum.values(), + CompetitionEnum.values() + ); + } +} diff --git a/app/src/main/java/de/uni_marburg/powersort/benchmark/Filter.java b/app/src/main/java/de/uni_marburg/powersort/benchmark/Filter.java index a3d401f..353277b 100644 --- a/app/src/main/java/de/uni_marburg/powersort/benchmark/Filter.java +++ b/app/src/main/java/de/uni_marburg/powersort/benchmark/Filter.java @@ -1,5 +1,7 @@ package de.uni_marburg.powersort.benchmark; +import de.uni_marburg.powersort.data.CglEnum; +import de.uni_marburg.powersort.data.CompetitionEnum; import de.uni_marburg.powersort.data.DataEnum; import de.uni_marburg.powersort.data.IntegerSerializer; import de.uni_marburg.powersort.sort.SortEnum; @@ -7,6 +9,8 @@ import de.uni_marburg.powersort.sort.SortEnum; import java.nio.file.Files; import java.util.List; +import static de.uni_marburg.powersort.data.CompetitionEnum.isCompetitionInput; + public class Filter { /* Utility Class */ private Filter() { @@ -15,22 +19,22 @@ public class Filter { public static boolean isFiltered(DataEnum d, SortEnum s) { // To skip some of the inputs for all sort algorithms, uncomment them here. // if (List.of( -// DataEnum.RANDOM_INTEGERS_300M, -// DataEnum.ASCENDING_INTEGERS_300M, -// DataEnum.DESCENDING_INTEGERS_250M, -// DataEnum.ASCENDING_RUNS_1M, -// DataEnum.ASCENDING_RUNS_WITH_OVERLAP_1M +// CglEnum.RANDOM_INTEGERS_300M, +// CglEnum.ASCENDING_INTEGERS_300M, +// CglEnum.DESCENDING_INTEGERS_250M, +// CglEnum.ASCENDING_RUNS_1M, +// CglEnum.ASCENDING_RUNS_WITH_OVERLAP_1M // ).contains(d)) { // return true; // } // To skip all competition inputs, uncomment the next line. -// if(d.isCompetitionInput()){ +// if(isCompetitionInput(d)){ // return true; // } // Skip some sort algorithms for all competition inputs. - if(d.isCompetitionInput()){ + if(isCompetitionInput(d)){ if(List.of( SortEnum.BUBBLE_SORT, SortEnum.MERGE_SORT @@ -50,127 +54,127 @@ public class Filter { if (s == SortEnum.QUICK_SORT) { return List.of( - DataEnum.RANDOM_INTEGERS_300M, - DataEnum.ASCENDING_INTEGERS_300M, - DataEnum.DESCENDING_INTEGERS_250M, - DataEnum.ASCENDING_RUNS_1M, - DataEnum.ASCENDING_RUNS_WITH_OVERLAP_1M, + CglEnum.RANDOM_INTEGERS_300M, + CglEnum.ASCENDING_INTEGERS_300M, + CglEnum.DESCENDING_INTEGERS_250M, + CglEnum.ASCENDING_RUNS_1M, + CglEnum.ASCENDING_RUNS_WITH_OVERLAP_1M, - DataEnum.COMPETITION_34, - DataEnum.COMPETITION_35, - DataEnum.COMPETITION_36, - DataEnum.COMPETITION_37, - DataEnum.COMPETITION_38, - DataEnum.COMPETITION_39, - DataEnum.COMPETITION_83, - DataEnum.COMPETITION_85, - DataEnum.COMPETITION_153, - DataEnum.COMPETITION_163, - DataEnum.COMPETITION_164, - DataEnum.COMPETITION_165, - DataEnum.COMPETITION_166, - DataEnum.COMPETITION_167, - DataEnum.COMPETITION_168, - DataEnum.COMPETITION_169, - DataEnum.COMPETITION_170, - DataEnum.COMPETITION_171, - DataEnum.COMPETITION_172, - DataEnum.COMPETITION_173, - DataEnum.COMPETITION_174, - DataEnum.COMPETITION_181, - DataEnum.COMPETITION_182, - DataEnum.COMPETITION_183, - DataEnum.COMPETITION_184, - DataEnum.COMPETITION_185, - DataEnum.COMPETITION_186, - DataEnum.COMPETITION_187, - DataEnum.COMPETITION_205, - DataEnum.COMPETITION_206, - DataEnum.COMPETITION_207, - DataEnum.COMPETITION_213, - DataEnum.COMPETITION_214, - DataEnum.COMPETITION_216, - DataEnum.COMPETITION_218, - DataEnum.COMPETITION_220, - DataEnum.COMPETITION_222, - DataEnum.COMPETITION_225, - DataEnum.COMPETITION_226, - DataEnum.COMPETITION_228, - DataEnum.COMPETITION_231, - DataEnum.COMPETITION_232, - DataEnum.COMPETITION_235, - DataEnum.COMPETITION_236 + CompetitionEnum.COMPETITION_34, + CompetitionEnum.COMPETITION_35, + CompetitionEnum.COMPETITION_36, + CompetitionEnum.COMPETITION_37, + CompetitionEnum.COMPETITION_38, + CompetitionEnum.COMPETITION_39, + CompetitionEnum.COMPETITION_83, + CompetitionEnum.COMPETITION_85, + CompetitionEnum.COMPETITION_153, + CompetitionEnum.COMPETITION_163, + CompetitionEnum.COMPETITION_164, + CompetitionEnum.COMPETITION_165, + CompetitionEnum.COMPETITION_166, + CompetitionEnum.COMPETITION_167, + CompetitionEnum.COMPETITION_168, + CompetitionEnum.COMPETITION_169, + CompetitionEnum.COMPETITION_170, + CompetitionEnum.COMPETITION_171, + CompetitionEnum.COMPETITION_172, + CompetitionEnum.COMPETITION_173, + CompetitionEnum.COMPETITION_174, + CompetitionEnum.COMPETITION_181, + CompetitionEnum.COMPETITION_182, + CompetitionEnum.COMPETITION_183, + CompetitionEnum.COMPETITION_184, + CompetitionEnum.COMPETITION_185, + CompetitionEnum.COMPETITION_186, + CompetitionEnum.COMPETITION_187, + CompetitionEnum.COMPETITION_205, + CompetitionEnum.COMPETITION_206, + CompetitionEnum.COMPETITION_207, + CompetitionEnum.COMPETITION_213, + CompetitionEnum.COMPETITION_214, + CompetitionEnum.COMPETITION_216, + CompetitionEnum.COMPETITION_218, + CompetitionEnum.COMPETITION_220, + CompetitionEnum.COMPETITION_222, + CompetitionEnum.COMPETITION_225, + CompetitionEnum.COMPETITION_226, + CompetitionEnum.COMPETITION_228, + CompetitionEnum.COMPETITION_231, + CompetitionEnum.COMPETITION_232, + CompetitionEnum.COMPETITION_235, + CompetitionEnum.COMPETITION_236 ).contains(d); } if (s == SortEnum.MERGE_SORT) { return List.of( - DataEnum.RANDOM_INTEGERS_300M, - DataEnum.ASCENDING_INTEGERS_300M, - DataEnum.DESCENDING_INTEGERS_250M + CglEnum.RANDOM_INTEGERS_300M, + CglEnum.ASCENDING_INTEGERS_300M, + CglEnum.DESCENDING_INTEGERS_250M ).contains(d); } if (s == SortEnum.BUBBLE_SORT) { return List.of( - DataEnum.DESCENDING_INTEGERS_250M, - DataEnum.ASCENDING_RUNS_1M, - DataEnum.ASCENDING_RUNS_WITH_OVERLAP_1M + CglEnum.DESCENDING_INTEGERS_250M, + CglEnum.ASCENDING_RUNS_1M, + CglEnum.ASCENDING_RUNS_WITH_OVERLAP_1M ).contains(d); } // TODO: Remove this once performance of FinnSort improved if (s == SortEnum.FINN_SORT) { return List.of( - DataEnum.DESCENDING_INTEGERS_250M, - DataEnum.ASCENDING_RUNS_1M, + CglEnum.DESCENDING_INTEGERS_250M, + CglEnum.ASCENDING_RUNS_1M, - DataEnum.COMPETITION_83, - DataEnum.COMPETITION_85, - DataEnum.COMPETITION_153, - DataEnum.COMPETITION_163, - DataEnum.COMPETITION_164, - DataEnum.COMPETITION_165, - DataEnum.COMPETITION_166, - DataEnum.COMPETITION_167, - DataEnum.COMPETITION_168, - DataEnum.COMPETITION_169, - DataEnum.COMPETITION_170, - DataEnum.COMPETITION_171, - DataEnum.COMPETITION_172, - DataEnum.COMPETITION_173, - DataEnum.COMPETITION_174, - DataEnum.COMPETITION_181, - DataEnum.COMPETITION_182, - DataEnum.COMPETITION_183, - DataEnum.COMPETITION_184, - DataEnum.COMPETITION_185, - DataEnum.COMPETITION_186, - DataEnum.COMPETITION_187, - DataEnum.COMPETITION_198, - DataEnum.COMPETITION_199, - DataEnum.COMPETITION_205, - DataEnum.COMPETITION_206, - DataEnum.COMPETITION_207, - DataEnum.COMPETITION_213, - DataEnum.COMPETITION_214, - DataEnum.COMPETITION_216, - DataEnum.COMPETITION_218, - DataEnum.COMPETITION_220, - DataEnum.COMPETITION_222, - DataEnum.COMPETITION_226, - DataEnum.COMPETITION_228, - DataEnum.COMPETITION_231, - DataEnum.COMPETITION_232, - DataEnum.COMPETITION_236 + CompetitionEnum.COMPETITION_83, + CompetitionEnum.COMPETITION_85, + CompetitionEnum.COMPETITION_153, + CompetitionEnum.COMPETITION_163, + CompetitionEnum.COMPETITION_164, + CompetitionEnum.COMPETITION_165, + CompetitionEnum.COMPETITION_166, + CompetitionEnum.COMPETITION_167, + CompetitionEnum.COMPETITION_168, + CompetitionEnum.COMPETITION_169, + CompetitionEnum.COMPETITION_170, + CompetitionEnum.COMPETITION_171, + CompetitionEnum.COMPETITION_172, + CompetitionEnum.COMPETITION_173, + CompetitionEnum.COMPETITION_174, + CompetitionEnum.COMPETITION_181, + CompetitionEnum.COMPETITION_182, + CompetitionEnum.COMPETITION_183, + CompetitionEnum.COMPETITION_184, + CompetitionEnum.COMPETITION_185, + CompetitionEnum.COMPETITION_186, + CompetitionEnum.COMPETITION_187, + CompetitionEnum.COMPETITION_198, + CompetitionEnum.COMPETITION_199, + CompetitionEnum.COMPETITION_205, + CompetitionEnum.COMPETITION_206, + CompetitionEnum.COMPETITION_207, + CompetitionEnum.COMPETITION_213, + CompetitionEnum.COMPETITION_214, + CompetitionEnum.COMPETITION_216, + CompetitionEnum.COMPETITION_218, + CompetitionEnum.COMPETITION_220, + CompetitionEnum.COMPETITION_222, + CompetitionEnum.COMPETITION_226, + CompetitionEnum.COMPETITION_228, + CompetitionEnum.COMPETITION_231, + CompetitionEnum.COMPETITION_232, + CompetitionEnum.COMPETITION_236 ).contains(d); } // TODO: Remove this once performance of ASort improved if (s == SortEnum.ASORT) { return List.of( - DataEnum.COMPETITION_173, - DataEnum.COMPETITION_174 + CompetitionEnum.COMPETITION_173, + CompetitionEnum.COMPETITION_174 ).contains(d); } diff --git a/app/src/main/java/de/uni_marburg/powersort/data/CglEnum.java b/app/src/main/java/de/uni_marburg/powersort/data/CglEnum.java new file mode 100644 index 0000000..94da3e1 --- /dev/null +++ b/app/src/main/java/de/uni_marburg/powersort/data/CglEnum.java @@ -0,0 +1,33 @@ +package de.uni_marburg.powersort.data; + +/** + * Enumeration of Custom Generated Lists (CGL). + */ +public enum CglEnum implements DataEnum{ + RANDOM_INTEGERS_300M, + ASCENDING_INTEGERS_300M, + DESCENDING_INTEGERS_250M, + ASCENDING_RUNS_1M, + ASCENDING_RUNS_WITH_OVERLAP_1M; + + @Override + public ObjectSupplier getObjectSupplier() { + // We use a seed to get the same random list every time -> Repeatable benchmarks on same input data! + // final long seed = 3651660232967549736L; // System.nanoTime() ++ Math.random() + final long seed = 140506881906827520L; // (long) 'P' * (long) 'O' *(long) 'W' * (long) 'E' * (long) 'R' * (long) 'S' * (long) 'O' * (long) 'R' * (long) 'T'; + + int longListSize = 300_000_000; // Any larger: Out of Heap Space. TODO GRADLE config + int middleListSize = 250_000_000; + int runs = 1_000; + int runLength = 1_000; + + return switch (this) { + case RANDOM_INTEGERS_300M -> new RandomIntegers(longListSize, seed); + case ASCENDING_INTEGERS_300M -> new AscendingIntegers(longListSize); + case DESCENDING_INTEGERS_250M -> new DescendingIntegers(middleListSize); + case ASCENDING_RUNS_1M -> AscendingRuns.newAscendingRuns(runs, runLength, -runLength); + case ASCENDING_RUNS_WITH_OVERLAP_1M -> + AscendingRuns.newAscendingRuns(runs, runLength, (int) (-0.5 * runLength)); + }; + } +} diff --git a/app/src/main/java/de/uni_marburg/powersort/data/CompetitionEnum.java b/app/src/main/java/de/uni_marburg/powersort/data/CompetitionEnum.java new file mode 100644 index 0000000..074a7ab --- /dev/null +++ b/app/src/main/java/de/uni_marburg/powersort/data/CompetitionEnum.java @@ -0,0 +1,500 @@ +package de.uni_marburg.powersort.data; + +/** + * Enumeration of integer lists from the Powersort competition. + */ +public enum CompetitionEnum implements DataEnum { + COMPETITION_1, + COMPETITION_2, + COMPETITION_3, + // COMPETITION_4, // Invalid input file. + COMPETITION_5, + COMPETITION_6, + COMPETITION_7, + COMPETITION_8, + COMPETITION_9, + COMPETITION_10, + COMPETITION_11, + COMPETITION_12, + COMPETITION_13, + // COMPETITION_14, // Invalid input file. + COMPETITION_15, + COMPETITION_16, + COMPETITION_17, + COMPETITION_18, + COMPETITION_19, + COMPETITION_20, + COMPETITION_21, + COMPETITION_22, + COMPETITION_23, + COMPETITION_24, + COMPETITION_25, + COMPETITION_26, + COMPETITION_27, + COMPETITION_28, + COMPETITION_29, + COMPETITION_30, + COMPETITION_31, + COMPETITION_32, + COMPETITION_33, + COMPETITION_34, + COMPETITION_35, + COMPETITION_36, + COMPETITION_37, + COMPETITION_38, + COMPETITION_39, + COMPETITION_40, + COMPETITION_41, + COMPETITION_42, + COMPETITION_43, + COMPETITION_44, + COMPETITION_45, + COMPETITION_46, + COMPETITION_47, + COMPETITION_48, + COMPETITION_49, + COMPETITION_50, + COMPETITION_51, + COMPETITION_52, + COMPETITION_53, + COMPETITION_54, + COMPETITION_55, + COMPETITION_56, + COMPETITION_57, + COMPETITION_58, + COMPETITION_59, + COMPETITION_60, + COMPETITION_61, + COMPETITION_62, + COMPETITION_63, + COMPETITION_64, + COMPETITION_65, + COMPETITION_66, + COMPETITION_67, + COMPETITION_68, + COMPETITION_69, + COMPETITION_70, + COMPETITION_71, + COMPETITION_72, + COMPETITION_73, + COMPETITION_74, + COMPETITION_75, + COMPETITION_76, + COMPETITION_77, + COMPETITION_78, + COMPETITION_79, + COMPETITION_80, + COMPETITION_81, + COMPETITION_82, + COMPETITION_83, + COMPETITION_84, + COMPETITION_85, + COMPETITION_86, + COMPETITION_87, + COMPETITION_88, + COMPETITION_89, + COMPETITION_90, + COMPETITION_91, + COMPETITION_92, + COMPETITION_93, + COMPETITION_94, + COMPETITION_95, + COMPETITION_96, + COMPETITION_97, + // COMPETITION_98, // Invalid input file (floats not integers). + COMPETITION_99, + COMPETITION_100, + COMPETITION_101, + COMPETITION_102, + COMPETITION_103, + COMPETITION_104, + COMPETITION_105, + COMPETITION_106, + COMPETITION_107, + COMPETITION_108, + COMPETITION_109, + COMPETITION_110, + COMPETITION_111, + COMPETITION_112, + COMPETITION_113, + COMPETITION_114, + COMPETITION_115, + COMPETITION_116, + COMPETITION_117, + COMPETITION_118, + COMPETITION_119, + COMPETITION_120, + COMPETITION_121, + COMPETITION_122, + COMPETITION_123, + COMPETITION_124, + COMPETITION_125, + COMPETITION_126, + COMPETITION_127, + COMPETITION_128, + COMPETITION_129, + COMPETITION_130, + COMPETITION_131, + COMPETITION_132, + COMPETITION_133, + COMPETITION_134, + COMPETITION_135, + COMPETITION_136, + COMPETITION_137, + COMPETITION_138, + COMPETITION_139, + COMPETITION_140, + COMPETITION_141, + COMPETITION_142, + COMPETITION_143, + COMPETITION_144, + COMPETITION_145, + COMPETITION_146, + COMPETITION_147, + COMPETITION_148, + COMPETITION_149, + COMPETITION_150, + COMPETITION_151, + COMPETITION_152, + COMPETITION_153, + COMPETITION_154, + COMPETITION_155, + COMPETITION_156, + COMPETITION_157, + COMPETITION_158, + COMPETITION_159, + COMPETITION_160, + COMPETITION_161, + COMPETITION_162, + COMPETITION_163, + COMPETITION_164, + COMPETITION_165, + COMPETITION_166, + COMPETITION_167, + COMPETITION_168, + COMPETITION_169, + COMPETITION_170, + COMPETITION_171, + COMPETITION_172, + COMPETITION_173, + COMPETITION_174, + COMPETITION_175, + COMPETITION_176, + COMPETITION_177, + COMPETITION_178, + COMPETITION_179, + COMPETITION_180, + COMPETITION_181, + COMPETITION_182, + COMPETITION_183, + COMPETITION_184, + COMPETITION_185, + COMPETITION_186, + COMPETITION_187, + COMPETITION_188, + COMPETITION_189, + COMPETITION_190, + COMPETITION_191, + COMPETITION_192, + COMPETITION_193, + COMPETITION_194, + COMPETITION_195, + COMPETITION_196, + COMPETITION_197, + COMPETITION_198, + COMPETITION_199, + COMPETITION_200, + COMPETITION_201, + COMPETITION_202, + COMPETITION_203, + COMPETITION_204, + COMPETITION_205, + COMPETITION_206, + COMPETITION_207, + COMPETITION_208, + COMPETITION_209, + COMPETITION_210, + COMPETITION_211, + COMPETITION_212, + COMPETITION_213, + COMPETITION_214, + COMPETITION_215, + COMPETITION_216, + COMPETITION_217, + COMPETITION_218, + COMPETITION_219, + COMPETITION_220, + COMPETITION_221, + COMPETITION_222, + COMPETITION_223, + COMPETITION_224, + COMPETITION_225, + COMPETITION_226, + COMPETITION_227, + COMPETITION_228, + COMPETITION_229, + COMPETITION_230, + COMPETITION_231, + COMPETITION_232, + COMPETITION_233, + COMPETITION_234, + COMPETITION_235, + COMPETITION_236, + COMPETITION_237, + COMPETITION_238; + + public static final String COMPETITION_PREFIX = "COMPETITION_"; + + public static boolean isCompetitionInput(DataEnum dataEnum) { + if (dataEnum instanceof CompetitionEnum) { + return ((CompetitionEnum) dataEnum).isCompetitionInput(); + } else { + return false; + } + } + + public boolean isCompetitionInput() { + return this.toString().startsWith(COMPETITION_PREFIX); + } + + @Override + public ObjectSupplier getObjectSupplier() { + return switch (this) { + case COMPETITION_1 -> IntegerSerializer.fromEnum(this); + case COMPETITION_2 -> IntegerSerializer.fromEnum(this); + case COMPETITION_3 -> IntegerSerializer.fromEnum(this); + case COMPETITION_5 -> IntegerSerializer.fromEnum(this); + case COMPETITION_6 -> IntegerSerializer.fromEnum(this); + case COMPETITION_7 -> IntegerSerializer.fromEnum(this); + case COMPETITION_8 -> IntegerSerializer.fromEnum(this); + case COMPETITION_9 -> IntegerSerializer.fromEnum(this); + case COMPETITION_10 -> IntegerSerializer.fromEnum(this); + case COMPETITION_11 -> IntegerSerializer.fromEnum(this); + case COMPETITION_12 -> IntegerSerializer.fromEnum(this); + case COMPETITION_13 -> IntegerSerializer.fromEnum(this); + case COMPETITION_15 -> IntegerSerializer.fromEnum(this); + case COMPETITION_16 -> IntegerSerializer.fromEnum(this); + case COMPETITION_17 -> IntegerSerializer.fromEnum(this); + case COMPETITION_18 -> IntegerSerializer.fromEnum(this); + case COMPETITION_19 -> IntegerSerializer.fromEnum(this); + case COMPETITION_20 -> IntegerSerializer.fromEnum(this); + case COMPETITION_21 -> IntegerSerializer.fromEnum(this); + case COMPETITION_22 -> IntegerSerializer.fromEnum(this); + case COMPETITION_23 -> IntegerSerializer.fromEnum(this); + case COMPETITION_24 -> IntegerSerializer.fromEnum(this); + case COMPETITION_25 -> IntegerSerializer.fromEnum(this); + case COMPETITION_26 -> IntegerSerializer.fromEnum(this); + case COMPETITION_27 -> IntegerSerializer.fromEnum(this); + case COMPETITION_28 -> IntegerSerializer.fromEnum(this); + case COMPETITION_29 -> IntegerSerializer.fromEnum(this); + case COMPETITION_30 -> IntegerSerializer.fromEnum(this); + case COMPETITION_31 -> IntegerSerializer.fromEnum(this); + case COMPETITION_32 -> IntegerSerializer.fromEnum(this); + case COMPETITION_33 -> IntegerSerializer.fromEnum(this); + case COMPETITION_34 -> IntegerSerializer.fromEnum(this); + case COMPETITION_35 -> IntegerSerializer.fromEnum(this); + case COMPETITION_36 -> IntegerSerializer.fromEnum(this); + case COMPETITION_37 -> IntegerSerializer.fromEnum(this); + case COMPETITION_38 -> IntegerSerializer.fromEnum(this); + case COMPETITION_39 -> IntegerSerializer.fromEnum(this); + case COMPETITION_40 -> IntegerSerializer.fromEnum(this); + case COMPETITION_41 -> IntegerSerializer.fromEnum(this); + case COMPETITION_42 -> IntegerSerializer.fromEnum(this); + case COMPETITION_43 -> IntegerSerializer.fromEnum(this); + case COMPETITION_44 -> IntegerSerializer.fromEnum(this); + case COMPETITION_45 -> IntegerSerializer.fromEnum(this); + case COMPETITION_46 -> IntegerSerializer.fromEnum(this); + case COMPETITION_47 -> IntegerSerializer.fromEnum(this); + case COMPETITION_48 -> IntegerSerializer.fromEnum(this); + case COMPETITION_49 -> IntegerSerializer.fromEnum(this); + case COMPETITION_50 -> IntegerSerializer.fromEnum(this); + case COMPETITION_51 -> IntegerSerializer.fromEnum(this); + case COMPETITION_52 -> IntegerSerializer.fromEnum(this); + case COMPETITION_53 -> IntegerSerializer.fromEnum(this); + case COMPETITION_54 -> IntegerSerializer.fromEnum(this); + case COMPETITION_55 -> IntegerSerializer.fromEnum(this); + case COMPETITION_56 -> IntegerSerializer.fromEnum(this); + case COMPETITION_57 -> IntegerSerializer.fromEnum(this); + case COMPETITION_58 -> IntegerSerializer.fromEnum(this); + case COMPETITION_59 -> IntegerSerializer.fromEnum(this); + case COMPETITION_60 -> IntegerSerializer.fromEnum(this); + case COMPETITION_61 -> IntegerSerializer.fromEnum(this); + case COMPETITION_62 -> IntegerSerializer.fromEnum(this); + case COMPETITION_63 -> IntegerSerializer.fromEnum(this); + case COMPETITION_64 -> IntegerSerializer.fromEnum(this); + case COMPETITION_65 -> IntegerSerializer.fromEnum(this); + case COMPETITION_66 -> IntegerSerializer.fromEnum(this); + case COMPETITION_67 -> IntegerSerializer.fromEnum(this); + case COMPETITION_68 -> IntegerSerializer.fromEnum(this); + case COMPETITION_69 -> IntegerSerializer.fromEnum(this); + case COMPETITION_70 -> IntegerSerializer.fromEnum(this); + case COMPETITION_71 -> IntegerSerializer.fromEnum(this); + case COMPETITION_72 -> IntegerSerializer.fromEnum(this); + case COMPETITION_73 -> IntegerSerializer.fromEnum(this); + case COMPETITION_74 -> IntegerSerializer.fromEnum(this); + case COMPETITION_75 -> IntegerSerializer.fromEnum(this); + case COMPETITION_76 -> IntegerSerializer.fromEnum(this); + case COMPETITION_77 -> IntegerSerializer.fromEnum(this); + case COMPETITION_78 -> IntegerSerializer.fromEnum(this); + case COMPETITION_79 -> IntegerSerializer.fromEnum(this); + case COMPETITION_80 -> IntegerSerializer.fromEnum(this); + case COMPETITION_81 -> IntegerSerializer.fromEnum(this); + case COMPETITION_82 -> IntegerSerializer.fromEnum(this); + case COMPETITION_83 -> IntegerSerializer.fromEnum(this); + case COMPETITION_84 -> IntegerSerializer.fromEnum(this); + case COMPETITION_85 -> IntegerSerializer.fromEnum(this); + case COMPETITION_86 -> IntegerSerializer.fromEnum(this); + case COMPETITION_87 -> IntegerSerializer.fromEnum(this); + case COMPETITION_88 -> IntegerSerializer.fromEnum(this); + case COMPETITION_89 -> IntegerSerializer.fromEnum(this); + case COMPETITION_90 -> IntegerSerializer.fromEnum(this); + case COMPETITION_91 -> IntegerSerializer.fromEnum(this); + case COMPETITION_92 -> IntegerSerializer.fromEnum(this); + case COMPETITION_93 -> IntegerSerializer.fromEnum(this); + case COMPETITION_94 -> IntegerSerializer.fromEnum(this); + case COMPETITION_95 -> IntegerSerializer.fromEnum(this); + case COMPETITION_96 -> IntegerSerializer.fromEnum(this); + case COMPETITION_97 -> IntegerSerializer.fromEnum(this); + case COMPETITION_99 -> IntegerSerializer.fromEnum(this); + case COMPETITION_100 -> IntegerSerializer.fromEnum(this); + case COMPETITION_101 -> IntegerSerializer.fromEnum(this); + case COMPETITION_102 -> IntegerSerializer.fromEnum(this); + case COMPETITION_103 -> IntegerSerializer.fromEnum(this); + case COMPETITION_104 -> IntegerSerializer.fromEnum(this); + case COMPETITION_105 -> IntegerSerializer.fromEnum(this); + case COMPETITION_106 -> IntegerSerializer.fromEnum(this); + case COMPETITION_107 -> IntegerSerializer.fromEnum(this); + case COMPETITION_108 -> IntegerSerializer.fromEnum(this); + case COMPETITION_109 -> IntegerSerializer.fromEnum(this); + case COMPETITION_110 -> IntegerSerializer.fromEnum(this); + case COMPETITION_111 -> IntegerSerializer.fromEnum(this); + case COMPETITION_112 -> IntegerSerializer.fromEnum(this); + case COMPETITION_113 -> IntegerSerializer.fromEnum(this); + case COMPETITION_114 -> IntegerSerializer.fromEnum(this); + case COMPETITION_115 -> IntegerSerializer.fromEnum(this); + case COMPETITION_116 -> IntegerSerializer.fromEnum(this); + case COMPETITION_117 -> IntegerSerializer.fromEnum(this); + case COMPETITION_118 -> IntegerSerializer.fromEnum(this); + case COMPETITION_119 -> IntegerSerializer.fromEnum(this); + case COMPETITION_120 -> IntegerSerializer.fromEnum(this); + case COMPETITION_121 -> IntegerSerializer.fromEnum(this); + case COMPETITION_122 -> IntegerSerializer.fromEnum(this); + case COMPETITION_123 -> IntegerSerializer.fromEnum(this); + case COMPETITION_124 -> IntegerSerializer.fromEnum(this); + case COMPETITION_125 -> IntegerSerializer.fromEnum(this); + case COMPETITION_126 -> IntegerSerializer.fromEnum(this); + case COMPETITION_127 -> IntegerSerializer.fromEnum(this); + case COMPETITION_128 -> IntegerSerializer.fromEnum(this); + case COMPETITION_129 -> IntegerSerializer.fromEnum(this); + case COMPETITION_130 -> IntegerSerializer.fromEnum(this); + case COMPETITION_131 -> IntegerSerializer.fromEnum(this); + case COMPETITION_132 -> IntegerSerializer.fromEnum(this); + case COMPETITION_133 -> IntegerSerializer.fromEnum(this); + case COMPETITION_134 -> IntegerSerializer.fromEnum(this); + case COMPETITION_135 -> IntegerSerializer.fromEnum(this); + case COMPETITION_136 -> IntegerSerializer.fromEnum(this); + case COMPETITION_137 -> IntegerSerializer.fromEnum(this); + case COMPETITION_138 -> IntegerSerializer.fromEnum(this); + case COMPETITION_139 -> IntegerSerializer.fromEnum(this); + case COMPETITION_140 -> IntegerSerializer.fromEnum(this); + case COMPETITION_141 -> IntegerSerializer.fromEnum(this); + case COMPETITION_142 -> IntegerSerializer.fromEnum(this); + case COMPETITION_143 -> IntegerSerializer.fromEnum(this); + case COMPETITION_144 -> IntegerSerializer.fromEnum(this); + case COMPETITION_145 -> IntegerSerializer.fromEnum(this); + case COMPETITION_146 -> IntegerSerializer.fromEnum(this); + case COMPETITION_147 -> IntegerSerializer.fromEnum(this); + case COMPETITION_148 -> IntegerSerializer.fromEnum(this); + case COMPETITION_149 -> IntegerSerializer.fromEnum(this); + case COMPETITION_150 -> IntegerSerializer.fromEnum(this); + case COMPETITION_151 -> IntegerSerializer.fromEnum(this); + case COMPETITION_152 -> IntegerSerializer.fromEnum(this); + case COMPETITION_153 -> IntegerSerializer.fromEnum(this); + case COMPETITION_154 -> IntegerSerializer.fromEnum(this); + case COMPETITION_155 -> IntegerSerializer.fromEnum(this); + case COMPETITION_156 -> IntegerSerializer.fromEnum(this); + case COMPETITION_157 -> IntegerSerializer.fromEnum(this); + case COMPETITION_158 -> IntegerSerializer.fromEnum(this); + case COMPETITION_159 -> IntegerSerializer.fromEnum(this); + case COMPETITION_160 -> IntegerSerializer.fromEnum(this); + case COMPETITION_161 -> IntegerSerializer.fromEnum(this); + case COMPETITION_162 -> IntegerSerializer.fromEnum(this); + case COMPETITION_163 -> IntegerSerializer.fromEnum(this); + case COMPETITION_164 -> IntegerSerializer.fromEnum(this); + case COMPETITION_165 -> IntegerSerializer.fromEnum(this); + case COMPETITION_166 -> IntegerSerializer.fromEnum(this); + case COMPETITION_167 -> IntegerSerializer.fromEnum(this); + case COMPETITION_168 -> IntegerSerializer.fromEnum(this); + case COMPETITION_169 -> IntegerSerializer.fromEnum(this); + case COMPETITION_170 -> IntegerSerializer.fromEnum(this); + case COMPETITION_171 -> IntegerSerializer.fromEnum(this); + case COMPETITION_172 -> IntegerSerializer.fromEnum(this); + case COMPETITION_173 -> IntegerSerializer.fromEnum(this); + case COMPETITION_174 -> IntegerSerializer.fromEnum(this); + case COMPETITION_175 -> IntegerSerializer.fromEnum(this); + case COMPETITION_176 -> IntegerSerializer.fromEnum(this); + case COMPETITION_177 -> IntegerSerializer.fromEnum(this); + case COMPETITION_178 -> IntegerSerializer.fromEnum(this); + case COMPETITION_179 -> IntegerSerializer.fromEnum(this); + case COMPETITION_180 -> IntegerSerializer.fromEnum(this); + case COMPETITION_181 -> IntegerSerializer.fromEnum(this); + case COMPETITION_182 -> IntegerSerializer.fromEnum(this); + case COMPETITION_183 -> IntegerSerializer.fromEnum(this); + case COMPETITION_184 -> IntegerSerializer.fromEnum(this); + case COMPETITION_185 -> IntegerSerializer.fromEnum(this); + case COMPETITION_186 -> IntegerSerializer.fromEnum(this); + case COMPETITION_187 -> IntegerSerializer.fromEnum(this); + case COMPETITION_188 -> IntegerSerializer.fromEnum(this); + case COMPETITION_189 -> IntegerSerializer.fromEnum(this); + case COMPETITION_190 -> IntegerSerializer.fromEnum(this); + case COMPETITION_191 -> IntegerSerializer.fromEnum(this); + case COMPETITION_192 -> IntegerSerializer.fromEnum(this); + case COMPETITION_193 -> IntegerSerializer.fromEnum(this); + case COMPETITION_194 -> IntegerSerializer.fromEnum(this); + case COMPETITION_195 -> IntegerSerializer.fromEnum(this); + case COMPETITION_196 -> IntegerSerializer.fromEnum(this); + case COMPETITION_197 -> IntegerSerializer.fromEnum(this); + case COMPETITION_198 -> IntegerSerializer.fromEnum(this); + case COMPETITION_199 -> IntegerSerializer.fromEnum(this); + case COMPETITION_200 -> IntegerSerializer.fromEnum(this); + case COMPETITION_201 -> IntegerSerializer.fromEnum(this); + case COMPETITION_202 -> IntegerSerializer.fromEnum(this); + case COMPETITION_203 -> IntegerSerializer.fromEnum(this); + case COMPETITION_204 -> IntegerSerializer.fromEnum(this); + case COMPETITION_205 -> IntegerSerializer.fromEnum(this); + case COMPETITION_206 -> IntegerSerializer.fromEnum(this); + case COMPETITION_207 -> IntegerSerializer.fromEnum(this); + case COMPETITION_208 -> IntegerSerializer.fromEnum(this); + case COMPETITION_209 -> IntegerSerializer.fromEnum(this); + case COMPETITION_210 -> IntegerSerializer.fromEnum(this); + case COMPETITION_211 -> IntegerSerializer.fromEnum(this); + case COMPETITION_212 -> IntegerSerializer.fromEnum(this); + case COMPETITION_213 -> IntegerSerializer.fromEnum(this); + case COMPETITION_214 -> IntegerSerializer.fromEnum(this); + case COMPETITION_215 -> IntegerSerializer.fromEnum(this); + case COMPETITION_216 -> IntegerSerializer.fromEnum(this); + case COMPETITION_217 -> IntegerSerializer.fromEnum(this); + case COMPETITION_218 -> IntegerSerializer.fromEnum(this); + case COMPETITION_219 -> IntegerSerializer.fromEnum(this); + case COMPETITION_220 -> IntegerSerializer.fromEnum(this); + case COMPETITION_221 -> IntegerSerializer.fromEnum(this); + case COMPETITION_222 -> IntegerSerializer.fromEnum(this); + case COMPETITION_223 -> IntegerSerializer.fromEnum(this); + case COMPETITION_224 -> IntegerSerializer.fromEnum(this); + case COMPETITION_225 -> IntegerSerializer.fromEnum(this); + case COMPETITION_226 -> IntegerSerializer.fromEnum(this); + case COMPETITION_227 -> IntegerSerializer.fromEnum(this); + case COMPETITION_228 -> IntegerSerializer.fromEnum(this); + case COMPETITION_229 -> IntegerSerializer.fromEnum(this); + case COMPETITION_230 -> IntegerSerializer.fromEnum(this); + case COMPETITION_231 -> IntegerSerializer.fromEnum(this); + case COMPETITION_232 -> IntegerSerializer.fromEnum(this); + case COMPETITION_233 -> IntegerSerializer.fromEnum(this); + case COMPETITION_234 -> IntegerSerializer.fromEnum(this); + case COMPETITION_235 -> IntegerSerializer.fromEnum(this); + case COMPETITION_236 -> IntegerSerializer.fromEnum(this); + case COMPETITION_237 -> IntegerSerializer.fromEnum(this); + case COMPETITION_238 -> IntegerSerializer.fromEnum(this); + }; + } +} diff --git a/app/src/main/java/de/uni_marburg/powersort/data/DataEnum.java b/app/src/main/java/de/uni_marburg/powersort/data/DataEnum.java index e6aa2b9..ce2c2b4 100644 --- a/app/src/main/java/de/uni_marburg/powersort/data/DataEnum.java +++ b/app/src/main/java/de/uni_marburg/powersort/data/DataEnum.java @@ -1,510 +1,8 @@ package de.uni_marburg.powersort.data; -public enum DataEnum { - RANDOM_INTEGERS_300M, - ASCENDING_INTEGERS_300M, - DESCENDING_INTEGERS_250M, - ASCENDING_RUNS_1M, - ASCENDING_RUNS_WITH_OVERLAP_1M, - - COMPETITION_1, - COMPETITION_2, - COMPETITION_3, -// COMPETITION_4, // Invalid input file. - COMPETITION_5, - COMPETITION_6, - COMPETITION_7, - COMPETITION_8, - COMPETITION_9, - COMPETITION_10, - COMPETITION_11, - COMPETITION_12, - COMPETITION_13, -// COMPETITION_14, // Invalid input file. - COMPETITION_15, - COMPETITION_16, - COMPETITION_17, - COMPETITION_18, - COMPETITION_19, - COMPETITION_20, - COMPETITION_21, - COMPETITION_22, - COMPETITION_23, - COMPETITION_24, - COMPETITION_25, - COMPETITION_26, - COMPETITION_27, - COMPETITION_28, - COMPETITION_29, - COMPETITION_30, - COMPETITION_31, - COMPETITION_32, - COMPETITION_33, - COMPETITION_34, - COMPETITION_35, - COMPETITION_36, - COMPETITION_37, - COMPETITION_38, - COMPETITION_39, - COMPETITION_40, - COMPETITION_41, - COMPETITION_42, - COMPETITION_43, - COMPETITION_44, - COMPETITION_45, - COMPETITION_46, - COMPETITION_47, - COMPETITION_48, - COMPETITION_49, - COMPETITION_50, - COMPETITION_51, - COMPETITION_52, - COMPETITION_53, - COMPETITION_54, - COMPETITION_55, - COMPETITION_56, - COMPETITION_57, - COMPETITION_58, - COMPETITION_59, - COMPETITION_60, - COMPETITION_61, - COMPETITION_62, - COMPETITION_63, - COMPETITION_64, - COMPETITION_65, - COMPETITION_66, - COMPETITION_67, - COMPETITION_68, - COMPETITION_69, - COMPETITION_70, - COMPETITION_71, - COMPETITION_72, - COMPETITION_73, - COMPETITION_74, - COMPETITION_75, - COMPETITION_76, - COMPETITION_77, - COMPETITION_78, - COMPETITION_79, - COMPETITION_80, - COMPETITION_81, - COMPETITION_82, - COMPETITION_83, - COMPETITION_84, - COMPETITION_85, - COMPETITION_86, - COMPETITION_87, - COMPETITION_88, - COMPETITION_89, - COMPETITION_90, - COMPETITION_91, - COMPETITION_92, - COMPETITION_93, - COMPETITION_94, - COMPETITION_95, - COMPETITION_96, - COMPETITION_97, -// COMPETITION_98, // Invalid input file (floats not integers). - COMPETITION_99, - COMPETITION_100, - COMPETITION_101, - COMPETITION_102, - COMPETITION_103, - COMPETITION_104, - COMPETITION_105, - COMPETITION_106, - COMPETITION_107, - COMPETITION_108, - COMPETITION_109, - COMPETITION_110, - COMPETITION_111, - COMPETITION_112, - COMPETITION_113, - COMPETITION_114, - COMPETITION_115, - COMPETITION_116, - COMPETITION_117, - COMPETITION_118, - COMPETITION_119, - COMPETITION_120, - COMPETITION_121, - COMPETITION_122, - COMPETITION_123, - COMPETITION_124, - COMPETITION_125, - COMPETITION_126, - COMPETITION_127, - COMPETITION_128, - COMPETITION_129, - COMPETITION_130, - COMPETITION_131, - COMPETITION_132, - COMPETITION_133, - COMPETITION_134, - COMPETITION_135, - COMPETITION_136, - COMPETITION_137, - COMPETITION_138, - COMPETITION_139, - COMPETITION_140, - COMPETITION_141, - COMPETITION_142, - COMPETITION_143, - COMPETITION_144, - COMPETITION_145, - COMPETITION_146, - COMPETITION_147, - COMPETITION_148, - COMPETITION_149, - COMPETITION_150, - COMPETITION_151, - COMPETITION_152, - COMPETITION_153, - COMPETITION_154, - COMPETITION_155, - COMPETITION_156, - COMPETITION_157, - COMPETITION_158, - COMPETITION_159, - COMPETITION_160, - COMPETITION_161, - COMPETITION_162, - COMPETITION_163, - COMPETITION_164, - COMPETITION_165, - COMPETITION_166, - COMPETITION_167, - COMPETITION_168, - COMPETITION_169, - COMPETITION_170, - COMPETITION_171, - COMPETITION_172, - COMPETITION_173, - COMPETITION_174, - COMPETITION_175, - COMPETITION_176, - COMPETITION_177, - COMPETITION_178, - COMPETITION_179, - COMPETITION_180, - COMPETITION_181, - COMPETITION_182, - COMPETITION_183, - COMPETITION_184, - COMPETITION_185, - COMPETITION_186, - COMPETITION_187, - COMPETITION_188, - COMPETITION_189, - COMPETITION_190, - COMPETITION_191, - COMPETITION_192, - COMPETITION_193, - COMPETITION_194, - COMPETITION_195, - COMPETITION_196, - COMPETITION_197, - COMPETITION_198, - COMPETITION_199, - COMPETITION_200, - COMPETITION_201, - COMPETITION_202, - COMPETITION_203, - COMPETITION_204, - COMPETITION_205, - COMPETITION_206, - COMPETITION_207, - COMPETITION_208, - COMPETITION_209, - COMPETITION_210, - COMPETITION_211, - COMPETITION_212, - COMPETITION_213, - COMPETITION_214, - COMPETITION_215, - COMPETITION_216, - COMPETITION_217, - COMPETITION_218, - COMPETITION_219, - COMPETITION_220, - COMPETITION_221, - COMPETITION_222, - COMPETITION_223, - COMPETITION_224, - COMPETITION_225, - COMPETITION_226, - COMPETITION_227, - COMPETITION_228, - COMPETITION_229, - COMPETITION_230, - COMPETITION_231, - COMPETITION_232, - COMPETITION_233, - COMPETITION_234, - COMPETITION_235, - COMPETITION_236, - COMPETITION_237, - COMPETITION_238; - - public static final String COMPETITION_PREFIX = "COMPETITION_"; - - public boolean isCompetitionInput(){ - return this.toString().startsWith(COMPETITION_PREFIX); - } - - public ObjectSupplier getObjectSupplier() { - // We use a seed to get the same random list every time -> Repeatable benchmarks on same input data! - // final long seed = 3651660232967549736L; // System.nanoTime() ++ Math.random() - final long seed = 140506881906827520L; // (long) 'P' * (long) 'O' *(long) 'W' * (long) 'E' * (long) 'R' * (long) 'S' * (long) 'O' * (long) 'R' * (long) 'T'; - - int longListSize = 300_000_000; // Any larger: Out of Heap Space. TODO GRADLE config - int middleListSize = 250_000_000; - int runs = 1_000; - int runLength = 1_000; - - return switch (this) { - case RANDOM_INTEGERS_300M -> new RandomIntegers(longListSize, seed); - case ASCENDING_INTEGERS_300M -> new AscendingIntegers(longListSize); - case DESCENDING_INTEGERS_250M -> new DescendingIntegers(middleListSize); - case ASCENDING_RUNS_1M -> AscendingRuns.newAscendingRuns(runs, runLength, -runLength); - case ASCENDING_RUNS_WITH_OVERLAP_1M -> - AscendingRuns.newAscendingRuns(runs, runLength, (int) (-0.5 * runLength)); - - case COMPETITION_1 -> IntegerSerializer.fromEnum(this); - case COMPETITION_2 -> IntegerSerializer.fromEnum(this); - case COMPETITION_3 -> IntegerSerializer.fromEnum(this); - case COMPETITION_5 -> IntegerSerializer.fromEnum(this); - case COMPETITION_6 -> IntegerSerializer.fromEnum(this); - case COMPETITION_7 -> IntegerSerializer.fromEnum(this); - case COMPETITION_8 -> IntegerSerializer.fromEnum(this); - case COMPETITION_9 -> IntegerSerializer.fromEnum(this); - case COMPETITION_10 -> IntegerSerializer.fromEnum(this); - case COMPETITION_11 -> IntegerSerializer.fromEnum(this); - case COMPETITION_12 -> IntegerSerializer.fromEnum(this); - case COMPETITION_13 -> IntegerSerializer.fromEnum(this); - case COMPETITION_15 -> IntegerSerializer.fromEnum(this); - case COMPETITION_16 -> IntegerSerializer.fromEnum(this); - case COMPETITION_17 -> IntegerSerializer.fromEnum(this); - case COMPETITION_18 -> IntegerSerializer.fromEnum(this); - case COMPETITION_19 -> IntegerSerializer.fromEnum(this); - case COMPETITION_20 -> IntegerSerializer.fromEnum(this); - case COMPETITION_21 -> IntegerSerializer.fromEnum(this); - case COMPETITION_22 -> IntegerSerializer.fromEnum(this); - case COMPETITION_23 -> IntegerSerializer.fromEnum(this); - case COMPETITION_24 -> IntegerSerializer.fromEnum(this); - case COMPETITION_25 -> IntegerSerializer.fromEnum(this); - case COMPETITION_26 -> IntegerSerializer.fromEnum(this); - case COMPETITION_27 -> IntegerSerializer.fromEnum(this); - case COMPETITION_28 -> IntegerSerializer.fromEnum(this); - case COMPETITION_29 -> IntegerSerializer.fromEnum(this); - case COMPETITION_30 -> IntegerSerializer.fromEnum(this); - case COMPETITION_31 -> IntegerSerializer.fromEnum(this); - case COMPETITION_32 -> IntegerSerializer.fromEnum(this); - case COMPETITION_33 -> IntegerSerializer.fromEnum(this); - case COMPETITION_34 -> IntegerSerializer.fromEnum(this); - case COMPETITION_35 -> IntegerSerializer.fromEnum(this); - case COMPETITION_36 -> IntegerSerializer.fromEnum(this); - case COMPETITION_37 -> IntegerSerializer.fromEnum(this); - case COMPETITION_38 -> IntegerSerializer.fromEnum(this); - case COMPETITION_39 -> IntegerSerializer.fromEnum(this); - case COMPETITION_40 -> IntegerSerializer.fromEnum(this); - case COMPETITION_41 -> IntegerSerializer.fromEnum(this); - case COMPETITION_42 -> IntegerSerializer.fromEnum(this); - case COMPETITION_43 -> IntegerSerializer.fromEnum(this); - case COMPETITION_44 -> IntegerSerializer.fromEnum(this); - case COMPETITION_45 -> IntegerSerializer.fromEnum(this); - case COMPETITION_46 -> IntegerSerializer.fromEnum(this); - case COMPETITION_47 -> IntegerSerializer.fromEnum(this); - case COMPETITION_48 -> IntegerSerializer.fromEnum(this); - case COMPETITION_49 -> IntegerSerializer.fromEnum(this); - case COMPETITION_50 -> IntegerSerializer.fromEnum(this); - case COMPETITION_51 -> IntegerSerializer.fromEnum(this); - case COMPETITION_52 -> IntegerSerializer.fromEnum(this); - case COMPETITION_53 -> IntegerSerializer.fromEnum(this); - case COMPETITION_54 -> IntegerSerializer.fromEnum(this); - case COMPETITION_55 -> IntegerSerializer.fromEnum(this); - case COMPETITION_56 -> IntegerSerializer.fromEnum(this); - case COMPETITION_57 -> IntegerSerializer.fromEnum(this); - case COMPETITION_58 -> IntegerSerializer.fromEnum(this); - case COMPETITION_59 -> IntegerSerializer.fromEnum(this); - case COMPETITION_60 -> IntegerSerializer.fromEnum(this); - case COMPETITION_61 -> IntegerSerializer.fromEnum(this); - case COMPETITION_62 -> IntegerSerializer.fromEnum(this); - case COMPETITION_63 -> IntegerSerializer.fromEnum(this); - case COMPETITION_64 -> IntegerSerializer.fromEnum(this); - case COMPETITION_65 -> IntegerSerializer.fromEnum(this); - case COMPETITION_66 -> IntegerSerializer.fromEnum(this); - case COMPETITION_67 -> IntegerSerializer.fromEnum(this); - case COMPETITION_68 -> IntegerSerializer.fromEnum(this); - case COMPETITION_69 -> IntegerSerializer.fromEnum(this); - case COMPETITION_70 -> IntegerSerializer.fromEnum(this); - case COMPETITION_71 -> IntegerSerializer.fromEnum(this); - case COMPETITION_72 -> IntegerSerializer.fromEnum(this); - case COMPETITION_73 -> IntegerSerializer.fromEnum(this); - case COMPETITION_74 -> IntegerSerializer.fromEnum(this); - case COMPETITION_75 -> IntegerSerializer.fromEnum(this); - case COMPETITION_76 -> IntegerSerializer.fromEnum(this); - case COMPETITION_77 -> IntegerSerializer.fromEnum(this); - case COMPETITION_78 -> IntegerSerializer.fromEnum(this); - case COMPETITION_79 -> IntegerSerializer.fromEnum(this); - case COMPETITION_80 -> IntegerSerializer.fromEnum(this); - case COMPETITION_81 -> IntegerSerializer.fromEnum(this); - case COMPETITION_82 -> IntegerSerializer.fromEnum(this); - case COMPETITION_83 -> IntegerSerializer.fromEnum(this); - case COMPETITION_84 -> IntegerSerializer.fromEnum(this); - case COMPETITION_85 -> IntegerSerializer.fromEnum(this); - case COMPETITION_86 -> IntegerSerializer.fromEnum(this); - case COMPETITION_87 -> IntegerSerializer.fromEnum(this); - case COMPETITION_88 -> IntegerSerializer.fromEnum(this); - case COMPETITION_89 -> IntegerSerializer.fromEnum(this); - case COMPETITION_90 -> IntegerSerializer.fromEnum(this); - case COMPETITION_91 -> IntegerSerializer.fromEnum(this); - case COMPETITION_92 -> IntegerSerializer.fromEnum(this); - case COMPETITION_93 -> IntegerSerializer.fromEnum(this); - case COMPETITION_94 -> IntegerSerializer.fromEnum(this); - case COMPETITION_95 -> IntegerSerializer.fromEnum(this); - case COMPETITION_96 -> IntegerSerializer.fromEnum(this); - case COMPETITION_97 -> IntegerSerializer.fromEnum(this); - case COMPETITION_99 -> IntegerSerializer.fromEnum(this); - case COMPETITION_100 -> IntegerSerializer.fromEnum(this); - case COMPETITION_101 -> IntegerSerializer.fromEnum(this); - case COMPETITION_102 -> IntegerSerializer.fromEnum(this); - case COMPETITION_103 -> IntegerSerializer.fromEnum(this); - case COMPETITION_104 -> IntegerSerializer.fromEnum(this); - case COMPETITION_105 -> IntegerSerializer.fromEnum(this); - case COMPETITION_106 -> IntegerSerializer.fromEnum(this); - case COMPETITION_107 -> IntegerSerializer.fromEnum(this); - case COMPETITION_108 -> IntegerSerializer.fromEnum(this); - case COMPETITION_109 -> IntegerSerializer.fromEnum(this); - case COMPETITION_110 -> IntegerSerializer.fromEnum(this); - case COMPETITION_111 -> IntegerSerializer.fromEnum(this); - case COMPETITION_112 -> IntegerSerializer.fromEnum(this); - case COMPETITION_113 -> IntegerSerializer.fromEnum(this); - case COMPETITION_114 -> IntegerSerializer.fromEnum(this); - case COMPETITION_115 -> IntegerSerializer.fromEnum(this); - case COMPETITION_116 -> IntegerSerializer.fromEnum(this); - case COMPETITION_117 -> IntegerSerializer.fromEnum(this); - case COMPETITION_118 -> IntegerSerializer.fromEnum(this); - case COMPETITION_119 -> IntegerSerializer.fromEnum(this); - case COMPETITION_120 -> IntegerSerializer.fromEnum(this); - case COMPETITION_121 -> IntegerSerializer.fromEnum(this); - case COMPETITION_122 -> IntegerSerializer.fromEnum(this); - case COMPETITION_123 -> IntegerSerializer.fromEnum(this); - case COMPETITION_124 -> IntegerSerializer.fromEnum(this); - case COMPETITION_125 -> IntegerSerializer.fromEnum(this); - case COMPETITION_126 -> IntegerSerializer.fromEnum(this); - case COMPETITION_127 -> IntegerSerializer.fromEnum(this); - case COMPETITION_128 -> IntegerSerializer.fromEnum(this); - case COMPETITION_129 -> IntegerSerializer.fromEnum(this); - case COMPETITION_130 -> IntegerSerializer.fromEnum(this); - case COMPETITION_131 -> IntegerSerializer.fromEnum(this); - case COMPETITION_132 -> IntegerSerializer.fromEnum(this); - case COMPETITION_133 -> IntegerSerializer.fromEnum(this); - case COMPETITION_134 -> IntegerSerializer.fromEnum(this); - case COMPETITION_135 -> IntegerSerializer.fromEnum(this); - case COMPETITION_136 -> IntegerSerializer.fromEnum(this); - case COMPETITION_137 -> IntegerSerializer.fromEnum(this); - case COMPETITION_138 -> IntegerSerializer.fromEnum(this); - case COMPETITION_139 -> IntegerSerializer.fromEnum(this); - case COMPETITION_140 -> IntegerSerializer.fromEnum(this); - case COMPETITION_141 -> IntegerSerializer.fromEnum(this); - case COMPETITION_142 -> IntegerSerializer.fromEnum(this); - case COMPETITION_143 -> IntegerSerializer.fromEnum(this); - case COMPETITION_144 -> IntegerSerializer.fromEnum(this); - case COMPETITION_145 -> IntegerSerializer.fromEnum(this); - case COMPETITION_146 -> IntegerSerializer.fromEnum(this); - case COMPETITION_147 -> IntegerSerializer.fromEnum(this); - case COMPETITION_148 -> IntegerSerializer.fromEnum(this); - case COMPETITION_149 -> IntegerSerializer.fromEnum(this); - case COMPETITION_150 -> IntegerSerializer.fromEnum(this); - case COMPETITION_151 -> IntegerSerializer.fromEnum(this); - case COMPETITION_152 -> IntegerSerializer.fromEnum(this); - case COMPETITION_153 -> IntegerSerializer.fromEnum(this); - case COMPETITION_154 -> IntegerSerializer.fromEnum(this); - case COMPETITION_155 -> IntegerSerializer.fromEnum(this); - case COMPETITION_156 -> IntegerSerializer.fromEnum(this); - case COMPETITION_157 -> IntegerSerializer.fromEnum(this); - case COMPETITION_158 -> IntegerSerializer.fromEnum(this); - case COMPETITION_159 -> IntegerSerializer.fromEnum(this); - case COMPETITION_160 -> IntegerSerializer.fromEnum(this); - case COMPETITION_161 -> IntegerSerializer.fromEnum(this); - case COMPETITION_162 -> IntegerSerializer.fromEnum(this); - case COMPETITION_163 -> IntegerSerializer.fromEnum(this); - case COMPETITION_164 -> IntegerSerializer.fromEnum(this); - case COMPETITION_165 -> IntegerSerializer.fromEnum(this); - case COMPETITION_166 -> IntegerSerializer.fromEnum(this); - case COMPETITION_167 -> IntegerSerializer.fromEnum(this); - case COMPETITION_168 -> IntegerSerializer.fromEnum(this); - case COMPETITION_169 -> IntegerSerializer.fromEnum(this); - case COMPETITION_170 -> IntegerSerializer.fromEnum(this); - case COMPETITION_171 -> IntegerSerializer.fromEnum(this); - case COMPETITION_172 -> IntegerSerializer.fromEnum(this); - case COMPETITION_173 -> IntegerSerializer.fromEnum(this); - case COMPETITION_174 -> IntegerSerializer.fromEnum(this); - case COMPETITION_175 -> IntegerSerializer.fromEnum(this); - case COMPETITION_176 -> IntegerSerializer.fromEnum(this); - case COMPETITION_177 -> IntegerSerializer.fromEnum(this); - case COMPETITION_178 -> IntegerSerializer.fromEnum(this); - case COMPETITION_179 -> IntegerSerializer.fromEnum(this); - case COMPETITION_180 -> IntegerSerializer.fromEnum(this); - case COMPETITION_181 -> IntegerSerializer.fromEnum(this); - case COMPETITION_182 -> IntegerSerializer.fromEnum(this); - case COMPETITION_183 -> IntegerSerializer.fromEnum(this); - case COMPETITION_184 -> IntegerSerializer.fromEnum(this); - case COMPETITION_185 -> IntegerSerializer.fromEnum(this); - case COMPETITION_186 -> IntegerSerializer.fromEnum(this); - case COMPETITION_187 -> IntegerSerializer.fromEnum(this); - case COMPETITION_188 -> IntegerSerializer.fromEnum(this); - case COMPETITION_189 -> IntegerSerializer.fromEnum(this); - case COMPETITION_190 -> IntegerSerializer.fromEnum(this); - case COMPETITION_191 -> IntegerSerializer.fromEnum(this); - case COMPETITION_192 -> IntegerSerializer.fromEnum(this); - case COMPETITION_193 -> IntegerSerializer.fromEnum(this); - case COMPETITION_194 -> IntegerSerializer.fromEnum(this); - case COMPETITION_195 -> IntegerSerializer.fromEnum(this); - case COMPETITION_196 -> IntegerSerializer.fromEnum(this); - case COMPETITION_197 -> IntegerSerializer.fromEnum(this); - case COMPETITION_198 -> IntegerSerializer.fromEnum(this); - case COMPETITION_199 -> IntegerSerializer.fromEnum(this); - case COMPETITION_200 -> IntegerSerializer.fromEnum(this); - case COMPETITION_201 -> IntegerSerializer.fromEnum(this); - case COMPETITION_202 -> IntegerSerializer.fromEnum(this); - case COMPETITION_203 -> IntegerSerializer.fromEnum(this); - case COMPETITION_204 -> IntegerSerializer.fromEnum(this); - case COMPETITION_205 -> IntegerSerializer.fromEnum(this); - case COMPETITION_206 -> IntegerSerializer.fromEnum(this); - case COMPETITION_207 -> IntegerSerializer.fromEnum(this); - case COMPETITION_208 -> IntegerSerializer.fromEnum(this); - case COMPETITION_209 -> IntegerSerializer.fromEnum(this); - case COMPETITION_210 -> IntegerSerializer.fromEnum(this); - case COMPETITION_211 -> IntegerSerializer.fromEnum(this); - case COMPETITION_212 -> IntegerSerializer.fromEnum(this); - case COMPETITION_213 -> IntegerSerializer.fromEnum(this); - case COMPETITION_214 -> IntegerSerializer.fromEnum(this); - case COMPETITION_215 -> IntegerSerializer.fromEnum(this); - case COMPETITION_216 -> IntegerSerializer.fromEnum(this); - case COMPETITION_217 -> IntegerSerializer.fromEnum(this); - case COMPETITION_218 -> IntegerSerializer.fromEnum(this); - case COMPETITION_219 -> IntegerSerializer.fromEnum(this); - case COMPETITION_220 -> IntegerSerializer.fromEnum(this); - case COMPETITION_221 -> IntegerSerializer.fromEnum(this); - case COMPETITION_222 -> IntegerSerializer.fromEnum(this); - case COMPETITION_223 -> IntegerSerializer.fromEnum(this); - case COMPETITION_224 -> IntegerSerializer.fromEnum(this); - case COMPETITION_225 -> IntegerSerializer.fromEnum(this); - case COMPETITION_226 -> IntegerSerializer.fromEnum(this); - case COMPETITION_227 -> IntegerSerializer.fromEnum(this); - case COMPETITION_228 -> IntegerSerializer.fromEnum(this); - case COMPETITION_229 -> IntegerSerializer.fromEnum(this); - case COMPETITION_230 -> IntegerSerializer.fromEnum(this); - case COMPETITION_231 -> IntegerSerializer.fromEnum(this); - case COMPETITION_232 -> IntegerSerializer.fromEnum(this); - case COMPETITION_233 -> IntegerSerializer.fromEnum(this); - case COMPETITION_234 -> IntegerSerializer.fromEnum(this); - case COMPETITION_235 -> IntegerSerializer.fromEnum(this); - case COMPETITION_236 -> IntegerSerializer.fromEnum(this); - case COMPETITION_237 -> IntegerSerializer.fromEnum(this); - case COMPETITION_238 -> IntegerSerializer.fromEnum(this); - }; - } +/** + * Interface for generic usage of different concrete Enum classes. + */ +public interface DataEnum { + ObjectSupplier getObjectSupplier(); } diff --git a/app/src/main/java/de/uni_marburg/powersort/data/IntegerSerializer.java b/app/src/main/java/de/uni_marburg/powersort/data/IntegerSerializer.java index 6604256..ef417a0 100644 --- a/app/src/main/java/de/uni_marburg/powersort/data/IntegerSerializer.java +++ b/app/src/main/java/de/uni_marburg/powersort/data/IntegerSerializer.java @@ -11,13 +11,13 @@ public class IntegerSerializer { private final int id; - public static ObjectSupplier fromEnum(DataEnum dataEnum) { - if(!dataEnum.isCompetitionInput()){ + public static ObjectSupplier fromEnum(CompetitionEnum dataEnum) { + if (!dataEnum.isCompetitionInput()) { throw new IllegalArgumentException(); } String prefixedId = dataEnum.toString(); - IntegerSerializer serializer = new IntegerSerializer(Integer.parseInt(prefixedId.substring(DataEnum.COMPETITION_PREFIX.length()))); + IntegerSerializer serializer = new IntegerSerializer(Integer.parseInt(prefixedId.substring(CompetitionEnum.COMPETITION_PREFIX.length()))); return serializer.getObjectSupplier(); }