Add benchmarking and trace build config
This commit is contained in:
@@ -2,3 +2,4 @@
|
||||
obj/
|
||||
bin/
|
||||
*.user
|
||||
BenchmarkDotNet.Artifacts/
|
||||
@@ -0,0 +1,97 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using BenchmarkDotNet.Engines;
|
||||
using Craftimizer.Simulator;
|
||||
using Craftimizer.Solver;
|
||||
|
||||
namespace Craftimizer.Benchmark;
|
||||
|
||||
[SimpleJob(RunStrategy.Monitoring)]
|
||||
[MinColumn, Q1Column, Q3Column, MaxColumn]
|
||||
public class Bench
|
||||
{
|
||||
private static SimulationInput[] Inputs { get; } = new SimulationInput[] {
|
||||
// https://craftingway.app/rotation/loud-namazu-jVe9Y
|
||||
// Chondrite Saw
|
||||
new(new()
|
||||
{
|
||||
Craftsmanship = 3304,
|
||||
Control = 3374,
|
||||
CP = 575,
|
||||
Level = 90,
|
||||
CanUseManipulation = true,
|
||||
HasSplendorousBuff = false,
|
||||
IsSpecialist = false,
|
||||
CLvl = 560,
|
||||
},
|
||||
new()
|
||||
{
|
||||
IsExpert = false,
|
||||
ClassJobLevel = 90,
|
||||
RLvl = 560,
|
||||
ConditionsFlag = 0b1111,
|
||||
MaxDurability = 80,
|
||||
MaxQuality = 7200,
|
||||
MaxProgress = 3500,
|
||||
QualityModifier = 80,
|
||||
QualityDivider = 115,
|
||||
ProgressModifier = 90,
|
||||
ProgressDivider = 130
|
||||
}),
|
||||
|
||||
// https://craftingway.app/rotation/sandy-fafnir-doVCs
|
||||
// Classical Longsword
|
||||
new(new()
|
||||
{
|
||||
Craftsmanship = 3290,
|
||||
Control = 3541,
|
||||
CP = 649,
|
||||
Level = 90,
|
||||
CanUseManipulation = true,
|
||||
HasSplendorousBuff = false,
|
||||
IsSpecialist = false,
|
||||
CLvl = 560,
|
||||
},
|
||||
new()
|
||||
{
|
||||
IsExpert = false,
|
||||
ClassJobLevel = 90,
|
||||
RLvl = 580,
|
||||
ConditionsFlag = 0b1111,
|
||||
MaxDurability = 70,
|
||||
MaxQuality = 10920,
|
||||
MaxProgress = 3900,
|
||||
QualityModifier = 70,
|
||||
QualityDivider = 115,
|
||||
ProgressModifier = 80,
|
||||
ProgressDivider = 130
|
||||
})
|
||||
};
|
||||
|
||||
public static IEnumerable<SimulationState> States => Inputs.Select(i => new SimulationState(i));
|
||||
|
||||
public static IEnumerable<SolverConfig> Configs => new SolverConfig[]
|
||||
{
|
||||
new()
|
||||
{
|
||||
Iterations = 100_000,
|
||||
ForkCount = 32,
|
||||
FurcatedActionCount = 16,
|
||||
MaxStepCount = 30,
|
||||
}
|
||||
};
|
||||
|
||||
[ParamsSource(nameof(States))]
|
||||
public SimulationState State { get; set; }
|
||||
|
||||
[ParamsSource(nameof(Configs))]
|
||||
public SolverConfig Config { get; set; }
|
||||
|
||||
[Benchmark]
|
||||
public async Task<float> Solve()
|
||||
{
|
||||
var solver = new Solver.Solver(Config, State);
|
||||
solver.Start();
|
||||
var (_, s) = await solver.GetTask().ConfigureAwait(false);
|
||||
return (float)s.Quality / s.Input.Recipe.MaxQuality;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>x64</Platforms>
|
||||
<Configurations>Debug;Release;Trace</Configurations>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using BenchmarkDotNet.Running;
|
||||
using Craftimizer.Simulator;
|
||||
using Craftimizer.Simulator.Actions;
|
||||
using Craftimizer.Solver;
|
||||
@@ -7,10 +8,11 @@ namespace Craftimizer.Benchmark;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
private static async Task Main()
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
//var summary = BenchmarkRunner.Run<Bench>();
|
||||
//return;
|
||||
Environment.SetEnvironmentVariable("IS_BENCH", "1");
|
||||
BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);
|
||||
return;
|
||||
|
||||
//TypeLayout.PrintLayout<ArenaNode<SimulationNode>>(true);
|
||||
//return;
|
||||
@@ -78,7 +80,7 @@ internal static class Program
|
||||
Console.WriteLine($"{state.Quality} {state.CP} {state.Progress} {state.Durability}");
|
||||
//return;
|
||||
var solver = new Solver.Solver(config, state);
|
||||
solver.OnLog += s => Console.WriteLine(s);
|
||||
solver.OnLog += Console.WriteLine;
|
||||
solver.OnNewAction += s => Console.WriteLine(s);
|
||||
solver.Start();
|
||||
var (_, s) = await solver.GetTask().ConfigureAwait(false);
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
<Platforms>x64</Platforms>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -21,4 +23,8 @@
|
||||
<ProjectReference Include="..\Solver\Craftimizer.Solver.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition="'$(IS_BENCH)'=='1'">$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Craftimizer.Simulator.Actions;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Craftimizer.Test.Simulator;
|
||||
|
||||
|
||||
@@ -105,6 +105,10 @@ public class ActionSetTests
|
||||
[TestMethod]
|
||||
public void TestRandomIndex()
|
||||
{
|
||||
#if IS_DETERMINISTIC
|
||||
Assert.Inconclusive("Craftimizer is built for benchmarking; all random actions are deterministic and not actually random.");
|
||||
#endif
|
||||
|
||||
var actions = new[]
|
||||
{
|
||||
ActionType.BasicTouch,
|
||||
|
||||
+26
-39
@@ -17,56 +17,43 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Craftimizer.Solver", "Solve
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3} = {172EE849-AC7E-4F2A-ACAB-EF9D065523B3}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Craftimizer.Test", "Craftimizer.Test\Craftimizer.Test.csproj", "{C3AEA981-9DA8-405C-995B-86528493891B}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Craftimizer.Test", "Craftimizer.Test\Craftimizer.Test.csproj", "{C3AEA981-9DA8-405C-995B-86528493891B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Trace|x64 = Trace|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Debug|x64.Build.0 = Debug|x64
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|Any CPU.Build.0 = Release|x64
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.ActiveCfg = Release|x64
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Release|x64.Build.0 = Release|x64
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Release|x64.Build.0 = Release|Any CPU
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{13C812E9-0D42-4B95-8646-40EEBF30636F}.Trace|x64.ActiveCfg = Release|x64
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Debug|x64.Build.0 = Debug|x64
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Release|x64.ActiveCfg = Release|x64
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Release|x64.Build.0 = Release|x64
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Trace|x64.ActiveCfg = Trace|x64
|
||||
{057C4B64-4D99-4847-9BCF-966571CAE57C}.Trace|x64.Build.0 = Trace|x64
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Debug|x64.Build.0 = Debug|x64
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Release|x64.ActiveCfg = Release|x64
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Release|x64.Build.0 = Release|x64
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Trace|x64.ActiveCfg = Trace|x64
|
||||
{172EE849-AC7E-4F2A-ACAB-EF9D065523B3}.Trace|x64.Build.0 = Trace|x64
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Debug|x64.Build.0 = Debug|x64
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Release|x64.ActiveCfg = Release|x64
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Release|x64.Build.0 = Release|x64
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Trace|x64.ActiveCfg = Trace|x64
|
||||
{2B0EA452-6DFC-48DB-9049-EA782E600C21}.Trace|x64.Build.0 = Trace|x64
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Debug|x64.Build.0 = Debug|x64
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Release|x64.ActiveCfg = Release|x64
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Release|x64.Build.0 = Release|x64
|
||||
{C3AEA981-9DA8-405C-995B-86528493891B}.Trace|x64.ActiveCfg = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<Authors>Asriel Camora</Authors>
|
||||
<Version>1.9.1.0</Version>
|
||||
<PackageProjectUrl>https://github.com/WorkingRobot/craftimizer.git</PackageProjectUrl>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>x64</Platforms>
|
||||
<Configurations>Debug;Release;Trace</Configurations>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -13,4 +15,9 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition="'$(IS_BENCH)'=='1'">$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
<DefineConstants Condition="'$(Configuration)' == 'Trace'">$(DefineConstants);IS_DETERMINISTIC;IS_TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -5,8 +5,6 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Craftimizer.Solver;
|
||||
|
||||
// #define IS_DETERMINISTIC
|
||||
|
||||
public struct ActionSet
|
||||
{
|
||||
private uint bits;
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<Platforms>x64</Platforms>
|
||||
<Configurations>Debug;Release;Trace</Configurations>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@@ -18,4 +20,9 @@
|
||||
<ProjectReference Include="..\Simulator\Craftimizer.Simulator.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<DefineConstants Condition="'$(IS_BENCH)'=='1'">$(DefineConstants);IS_DETERMINISTIC</DefineConstants>
|
||||
<DefineConstants Condition="'$(Configuration)' == 'Trace'">$(DefineConstants);IS_DETERMINISTIC;IS_TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user