Skip to content

Commit

Permalink
[skip ci] Remove duplicate code and rename variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Nov 1, 2021
1 parent b1bb69c commit 18ff6f7
Showing 1 changed file with 29 additions and 55 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,73 +218,47 @@ public static void main(String[] args) {
int maxLength = 50000000;
int maxKeyCount = 25000000;

Tester testClass = new Tester(maxLength, maxKeyCount);
Tester tester = new Tester(maxLength, maxKeyCount);
GrailComparator testCompare = new GrailComparator();

System.out.println("Warming-up the JVM...");

for(int u = 5; u <= (maxLength / 100); u *= 10) {
for(int v = 2; v <= u && v <= (maxKeyCount / 100); v *= 2) {
for(int i = 0; i < 3; i++) {
testClass.checkAlgorithm(0, u, v - 1, true, i, "All Strategies", testCompare);
tester.checkAlgorithm(0, u, v - 1, true, i, "All Strategies", testCompare);
}
}
}

System.out.println("\n*** Testing Holy Grail Sort against Tim Sort ***");

testClass.checkBoth( 0, 15, 4, "Opti.Gnome", testCompare);
testClass.checkBoth( 0, 15, 8, "Opti.Gnome", testCompare);
testClass.checkBoth( 7, 8, 4, "Opti.Gnome", testCompare);

testClass.checkBoth( 0, 1000000, 3, "Strategy 3", testCompare);
testClass.checkBoth( 0, 1000000, 1023, "Strategy 2", testCompare);
testClass.checkBoth( 0, 1000000, 500000, "Strategy 1", testCompare);
testClass.checkBoth( 500000, 500000, 3, "Strategy 3", testCompare);
testClass.checkBoth( 500000, 500000, 511, "Strategy 2", testCompare);
testClass.checkBoth( 500000, 500000, 250000, "Strategy 1", testCompare);

testClass.checkBoth( 0, 10000000, 3, "Strategy 3", testCompare);
testClass.checkBoth( 0, 10000000, 4095, "Strategy 2", testCompare);
testClass.checkBoth( 0, 10000000, 5000000, "Strategy 1", testCompare);
testClass.checkBoth( 5000000, 5000000, 3, "Strategy 3", testCompare);
testClass.checkBoth( 5000000, 5000000, 2047, "Strategy 2", testCompare);
testClass.checkBoth( 5000000, 5000000, 2500000, "Strategy 1", testCompare);

testClass.checkBoth( 0, 50000000, 3, "Strategy 3", testCompare);
testClass.checkBoth( 0, 50000000, 16383, "Strategy 2", testCompare);
testClass.checkBoth( 0, 50000000, 25000000, "Strategy 1", testCompare);
testClass.checkBoth(25000000, 25000000, 3, "Strategy 3", testCompare);
testClass.checkBoth(25000000, 25000000, 8191, "Strategy 2", testCompare);
testClass.checkBoth(25000000, 25000000, 12500000, "Strategy 1", testCompare);


testClass.checkBoth(25000000, 25000000, 12500000, "Strategy 1", testCompare);
testClass.checkBoth(25000000, 25000000, 8191, "Strategy 2", testCompare);
testClass.checkBoth(25000000, 25000000, 3, "Strategy 3", testCompare);
testClass.checkBoth( 0, 50000000, 25000000, "Strategy 1", testCompare);
testClass.checkBoth( 0, 50000000, 16383, "Strategy 2", testCompare);
testClass.checkBoth( 0, 50000000, 3, "Strategy 3", testCompare);

testClass.checkBoth( 5000000, 5000000, 2500000, "Strategy 1", testCompare);
testClass.checkBoth( 5000000, 5000000, 2047, "Strategy 2", testCompare);
testClass.checkBoth( 5000000, 5000000, 3, "Strategy 3", testCompare);
testClass.checkBoth( 0, 10000000, 5000000, "Strategy 1", testCompare);
testClass.checkBoth( 0, 10000000, 4095, "Strategy 2", testCompare);
testClass.checkBoth( 0, 10000000, 3, "Strategy 3", testCompare);

testClass.checkBoth( 500000, 500000, 250000, "Strategy 1", testCompare);
testClass.checkBoth( 500000, 500000, 511, "Strategy 2", testCompare);
testClass.checkBoth( 500000, 500000, 3, "Strategy 3", testCompare);
testClass.checkBoth( 0, 1000000, 500000, "Strategy 1", testCompare);
testClass.checkBoth( 0, 1000000, 1023, "Strategy 2", testCompare);
testClass.checkBoth( 0, 1000000, 3, "Strategy 3", testCompare);

testClass.checkBoth( 7, 8, 4, "Opti.Gnome", testCompare);
testClass.checkBoth( 0, 15, 8, "Opti.Gnome", testCompare);
testClass.checkBoth( 0, 15, 4, "Opti.Gnome", testCompare);

System.out.println("Ran " + testClass.count + " tests with " + testClass.successes + " success(es) and " + testClass.failures + " failure(s).");
System.exit(testClass.failures);
tester.checkBoth( 0, 15, 4, "Opti.Gnome", testCompare);
tester.checkBoth( 0, 15, 8, "Opti.Gnome", testCompare);
tester.checkBoth( 7, 8, 4, "Opti.Gnome", testCompare);

tester.checkBoth( 0, 1000000, 3, "Strategy 3", testCompare);
tester.checkBoth( 0, 1000000, 1023, "Strategy 2", testCompare);
tester.checkBoth( 0, 1000000, 500000, "Strategy 1", testCompare);
tester.checkBoth( 500000, 500000, 3, "Strategy 3", testCompare);
tester.checkBoth( 500000, 500000, 511, "Strategy 2", testCompare);
tester.checkBoth( 500000, 500000, 250000, "Strategy 1", testCompare);

tester.checkBoth( 0, 10000000, 3, "Strategy 3", testCompare);
tester.checkBoth( 0, 10000000, 4095, "Strategy 2", testCompare);
tester.checkBoth( 0, 10000000, 5000000, "Strategy 1", testCompare);
tester.checkBoth( 5000000, 5000000, 3, "Strategy 3", testCompare);
tester.checkBoth( 5000000, 5000000, 2047, "Strategy 2", testCompare);
tester.checkBoth( 5000000, 5000000, 2500000, "Strategy 1", testCompare);

tester.checkBoth( 0, 50000000, 3, "Strategy 3", testCompare);
tester.checkBoth( 0, 50000000, 16383, "Strategy 2", testCompare);
tester.checkBoth( 0, 50000000, 25000000, "Strategy 1", testCompare);
tester.checkBoth(25000000, 25000000, 3, "Strategy 3", testCompare);
tester.checkBoth(25000000, 25000000, 8191, "Strategy 2", testCompare);
tester.checkBoth(25000000, 25000000, 12500000, "Strategy 1", testCompare);

System.out.println("Ran " + tester.count + " tests with " + tester.successes + " success(es) and " + tester.failures + " failure(s).");
System.exit(tester.failures);
}
}

0 comments on commit 18ff6f7

Please sign in to comment.