diff --git a/Alligator.Benchmark/Alligator.Benchmark.csproj b/Alligator.Benchmark/Alligator.Benchmark.csproj
index c74effb..cca4082 100644
--- a/Alligator.Benchmark/Alligator.Benchmark.csproj
+++ b/Alligator.Benchmark/Alligator.Benchmark.csproj
@@ -12,4 +12,8 @@
+
+
+
+
diff --git a/Alligator.Benchmark/Program.cs b/Alligator.Benchmark/Program.cs
index dd58797..d4eb348 100644
--- a/Alligator.Benchmark/Program.cs
+++ b/Alligator.Benchmark/Program.cs
@@ -2,6 +2,7 @@
using Alligator.SixMaking.Model;
using Alligator.Solver;
using Alligator.Solver.Algorithms;
+using BenchmarkDotNet.Running;
using System.Diagnostics;
namespace Alligator.Benchmark
@@ -10,6 +11,12 @@ class Program
{
static void Main(string[] args)
{
+ if (args.Contains("--benchmark"))
+ {
+ BenchmarkRunner.Run();
+ return;
+ }
+
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Hello Six Making Benchmark!");
diff --git a/Alligator.Benchmark/Properties/launchSettings.json b/Alligator.Benchmark/Properties/launchSettings.json
new file mode 100644
index 0000000..d399d05
--- /dev/null
+++ b/Alligator.Benchmark/Properties/launchSettings.json
@@ -0,0 +1,12 @@
+{
+ "profiles": {
+ "Diagnostic": {
+ "commandName": "Project",
+ "commandLineArgs": ""
+ },
+ "BenchmarkDotNet": {
+ "commandName": "Project",
+ "commandLineArgs": "--benchmark"
+ }
+ }
+}
diff --git a/Alligator.Benchmark/SolverBenchmarks.cs b/Alligator.Benchmark/SolverBenchmarks.cs
new file mode 100644
index 0000000..458cc75
--- /dev/null
+++ b/Alligator.Benchmark/SolverBenchmarks.cs
@@ -0,0 +1,115 @@
+using Alligator.SixMaking.Logics;
+using Alligator.SixMaking.Model;
+using Alligator.Solver;
+using BenchmarkDotNet.Attributes;
+using BenchmarkDotNet.Engines;
+
+namespace Alligator.Benchmark
+{
+ [MemoryDiagnoser]
+ [SimpleJob(RunStrategy.Monitoring, warmupCount: 1, iterationCount: 5)]
+ public class SolverBenchmarks
+ {
+ private SolverProvider solverFactory = null!;
+ private ISolver solver = null!;
+ private IList example1History = null!;
+ private IList example2History = null!;
+ private IList example3History = null!;
+ private IList example5History = null!;
+
+ [GlobalSetup]
+ public void GlobalSetup()
+ {
+ var rules = new Rules(new StepPool(), new MovingRules());
+ var solverConfiguration = new Configuration();
+ solverFactory = new SolverProvider(rules, solverConfiguration);
+
+ example1History = BuildHistory(Example1());
+ example2History = BuildHistory(Example2());
+ example3History = BuildHistory(Example3());
+ example5History = BuildHistory(Example5());
+ }
+
+ [IterationSetup]
+ public void IterationSetup()
+ {
+ solver = solverFactory.Create();
+ }
+
+ [Benchmark(Description = "Example1 - Empty board")]
+ public Step Example1_EmptyBoard() => solver.OptimizeNextStep(example1History);
+
+ [Benchmark(Description = "Example2 - Four pieces")]
+ public Step Example2_FourPieces() => solver.OptimizeNextStep(example2History);
+
+ [Benchmark(Description = "Example3 - Twelve pieces")]
+ public Step Example3_TwelvePieces() => solver.OptimizeNextStep(example3History);
+
+ [Benchmark(Description = "Example5 - Complex midgame")]
+ public Step Example5_ComplexMidgame() => solver.OptimizeNextStep(example5History);
+
+ private static IList BuildHistory(IPosition position)
+ {
+ return position.History.ToList();
+ }
+
+ private static IPosition Example1()
+ {
+ return new Position();
+ }
+
+ private static IPosition Example2()
+ {
+ IPosition position = new Position();
+ position.Take(new Placement(12));
+ position.Take(new Placement(13));
+ position.Take(new Placement(11));
+ position.Take(new Placement(17));
+ return position;
+ }
+
+ private static IPosition Example3()
+ {
+ IPosition position = new Position();
+ for (int i = 6; i < 18; i++)
+ {
+ position.Take(new Placement(i));
+ }
+ return position;
+ }
+
+ private static IPosition Example5()
+ {
+ IPosition position = new Position();
+ position.Take(new Placement(0));
+ position.Take(new Placement(12));
+ position.Take(new Placement(1));
+ position.Take(new Placement(11));
+ position.Take(new Placement(2));
+ position.Take(new Placement(17));
+ position.Take(new Placement(3));
+ position.Take(new Placement(13));
+ position.Take(new Placement(4));
+ position.Take(new Placement(10));
+ position.Take(new Placement(5));
+ position.Take(new Placement(15));
+ position.Take(new Placement(20));
+ position.Take(new Placement(16));
+ position.Take(new Movement(5, 10, 1));
+ position.Take(new Movement(15, 10, 1));
+ position.Take(new Placement(5));
+ position.Take(new Placement(6));
+ position.Take(new Movement(1, 6, 1));
+ position.Take(new Movement(12, 11, 1));
+ position.Take(new Movement(10, 17, 1));
+ position.Take(new Placement(12));
+ position.Take(new Placement(7));
+ position.Take(new Placement(22));
+ position.Take(new Placement(1));
+ position.Take(new Movement(11, 16, 2));
+ position.Take(new Placement(21));
+ position.Take(new Placement(18));
+ return position;
+ }
+ }
+}