ConcurrentSolverPerformance

Compares the wall-clock time taken to solve the N-Queens counting problem with it.unibo.tuprolog.solve.concurrent.ConcurrentSolverFactory (backed by it.unibo.tuprolog.solve.concurrent.ConcurrentSolver, which explores alternative choice points on separate threads/coroutines) against the same query solved with it.unibo.tuprolog.solve.classic.ClassicSolverFactory (a single-threaded, depth-first resolution engine).

The theory is loaded from the bundled nQueens.pl resource, which counts (rather than enumerates) all solutions to the N-Queens problem for a given board size via queenCountSolution/2. This makes the example a useful, self-contained micro-benchmark for illustrating the trade-offs of :solve-concurrent versus :solve-classic: concurrent resolution can overlap the exploration of independent branches, but incurs coordination overhead that may or may not pay off depending on the problem size and hardware.

Properties

Link copied to clipboard
const val nQueens: Int = 8

The board size (and number of queens) used for the benchmark.

Link copied to clipboard

The query counting all solutions to the N-Queens problem for nQueens queens.

Link copied to clipboard

The N-Queens theory, parsed from the nQueens.pl classpath resource.

Functions

Link copied to clipboard
fun runClassic(theory: Theory, query: Struct)

Solves query against theory using the classic, single-threaded solver built via it.unibo.tuprolog.solve.classic.ClassicSolverFactory.solverWithDefaultBuiltins, and prints the elapsed time in milliseconds.

Link copied to clipboard
fun runConcurrent(theory: Theory, query: Struct)

Solves query against theory using a concurrent solver built via it.unibo.tuprolog.solve.concurrent.ConcurrentSolverFactory.solverWithDefaultBuiltins, and prints the elapsed time in milliseconds.