introduce bitloops
This commit is contained in:
@@ -5,6 +5,7 @@ import lombok.val;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import puzzle.Export.Clued;
|
||||
import puzzle.Export.Gridded;
|
||||
import puzzle.Masker.Clues;
|
||||
import puzzle.SwedishGenerator.DictEntry;
|
||||
import puzzle.SwedishGenerator.Rng;
|
||||
import puzzle.SwedishGenerator.Slotinfo;
|
||||
@@ -15,6 +16,9 @@ import static puzzle.SwedishGenerator.fillMask;
|
||||
public class PerformanceTest {
|
||||
|
||||
final DictEntry[] EN = DictData.DICT.index();
|
||||
void main() {
|
||||
testPerformance();
|
||||
}
|
||||
@Test
|
||||
void testPerformance() {
|
||||
val rng = new Rng(42);
|
||||
@@ -22,11 +26,13 @@ public class PerformanceTest {
|
||||
// 1. Stress test Clue Generation (Mask Generation)
|
||||
System.out.println("[DEBUG_LOG] --- Mask Generation Performance ---");
|
||||
int[] clueSizes = { 20, 25, 30 };
|
||||
var arr = new Clues[3];
|
||||
int c = 0;
|
||||
for (int size : clueSizes) {
|
||||
long t0 = System.currentTimeMillis();
|
||||
val masker = new Masker(rng, new int[SwedishGenerator.STACK_SIZE], Masker.Clues.createEmpty());
|
||||
// Increased population and generations for stress
|
||||
val mask = masker.generateMask(size, 200, 100, 50);
|
||||
arr[c++] = masker.generateMask(size, 200, 100, 50);
|
||||
long t1 = System.currentTimeMillis();
|
||||
double duration = (t1 - t0) / 1000.0;
|
||||
System.out.printf(Locale.ROOT, "[DEBUG_LOG] Size %d (pop=200, gen=100): %.3fs%n", size, duration);
|
||||
@@ -36,24 +42,24 @@ public class PerformanceTest {
|
||||
|
||||
// 2. Stress test Word Filler
|
||||
System.out.println("[DEBUG_LOG] \n--- Word Filler Performance ---");
|
||||
c = 0;
|
||||
for (int size : clueSizes) {
|
||||
val masker = new Masker(rng, new int[SwedishGenerator.STACK_SIZE], Masker.Clues.createEmpty());
|
||||
val mask = masker.generateMask(size, 100, 50, 20);
|
||||
|
||||
val slotInfo = Masker.slots(mask, EN);
|
||||
|
||||
long t0 = System.currentTimeMillis();
|
||||
// Try to fill multiple times to get a better average
|
||||
int iterations = 1;
|
||||
int iterations = 10;
|
||||
long totalNodes = 0;
|
||||
long totalBacktracks = 0;
|
||||
int successCount = 0;
|
||||
|
||||
for (int i = 0; i < iterations; i++) {
|
||||
val result = fillMask(rng, slotInfo, Slotinfo.grid(slotInfo));
|
||||
val slotInfo = Masker.slots(arr[c], EN);
|
||||
val result = fillMask(rng, slotInfo, Slotinfo.grid(slotInfo));
|
||||
if (result.ok()) successCount++;
|
||||
totalNodes += result.nodes();
|
||||
totalBacktracks += result.backtracks();
|
||||
}
|
||||
c++;
|
||||
long t1 = System.currentTimeMillis();
|
||||
double totalDuration = (t1 - t0) / 1000.0;
|
||||
|
||||
@@ -61,9 +67,6 @@ public class PerformanceTest {
|
||||
size, successCount, iterations, totalNodes / iterations, totalBacktracks / iterations, totalDuration);
|
||||
}
|
||||
}
|
||||
void main() {
|
||||
testIncrementalComplexity();
|
||||
}
|
||||
@Test
|
||||
void testIncrementalComplexity() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user