net.sourceforge.domian.test.benchmark
Class QueenPuzzleTestRunner
java.lang.Object
net.sourceforge.domian.test.benchmark.QueenPuzzleTestRunner
public class QueenPuzzleTestRunner
- extends java.lang.Object
An amusing little computing task involving (possible) vast numbers of repository inserts, updates, and search.
In detail, it consists of:
Generating random chess piece constellations consisting of 8 pieces, disguised as entity objects; adding them to a repository
A batch processing task, iterating through all constellations, doing a little check, with a conditional update
If the repository supports asynchronous persistence, all entities are persisted
A search task for all constellations solving the queen puzzle
A completion control search task for all constellations not processed (should be none)
The batch processing task tries to solve the infamous "Queen Puzzle" which seeks to find all possible chess queen piece constellations
where none of the queens are threatened by one of the other queens.
A standard 8 x 8 chess board and 8 queen pieces are hard-coded.
Possible sequences of queens are staggering 64^8 = 281.474.976.710.656 (over 280 trillions!)
The JVM flag -Xms should not be set when using this class. it seems to screw up the garbage collectioning...
Usage example:
java net.sourceforge.domian.test.benchmark.QueenPuzzleTestRunner seq [repo type] [#executions] [#constellations] [#log interval]
java net.sourceforge.domian.test.benchmark.QueenPuzzleTestRunner con [repo type] [#executions] [#constellations] [#worker threads] [#log interval]
seq
means sequential execution (one thread only), and con
means concurrent execution by a given number of worker threads.
The available repo type
s are:
#executions
is the number of iterating executions, always sequential.
#constellations
is the number of queen puzzle constellations, and thus the total number of entities the repository is to handle.
#log interval
is the number of generated/processed queen puzzle constellations between every emitted log message.
Usage example:
java -cp ... net.sourceforge.domian.test.benchmark.QueenPuzzleTestRunner con inmemory 1 100000 4 10000
Process 100000 queen puzzle constellations, using 4 threads.
Use the InMemoryRepository
.
Run the benchmark only once, and show status messages every for 10000 constellations.
- Author:
- Eirik Torske
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
executionStyle
private static java.lang.String executionStyle
QueenPuzzleTestRunner
public QueenPuzzleTestRunner()
main
public static void main(java.lang.String[] args)
printReport
private static void printReport(Repository<AbstractQueenPuzzle> repo)
getExecutionStyle
private static java.lang.String getExecutionStyle()
getNumberOfExecutions
private static long getNumberOfExecutions(Repository<AbstractQueenPuzzle> repo)
getRepositoryType
private static java.lang.String getRepositoryType(Repository<AbstractQueenPuzzle> repo)
getNumberOfConstellationsPerExecution
private static long getNumberOfConstellationsPerExecution(Repository<AbstractQueenPuzzle> repo)
getNumberOfWorkerThreadsPerExecution
private static int getNumberOfWorkerThreadsPerExecution(Repository<AbstractQueenPuzzle> repo)
Copyright © 2008-2010. All Rights Reserved.