Files
Craftimizer/Benchmark/Program.cs
T
Asriel Camora d5a8288439 Merge solver code with static interface
- Breaks backwards compat solver code with last version. Concurrent broke backwards compat because of race conditions with rng, but single is now broken too, despite it being 2x faster (!!!!)
- Literally twice as fast as Rust now in single thread
- Concurrent doesn't work yet, deadlocks somewhere..?
2023-07-07 10:26:59 +02:00

71 lines
2.0 KiB
C#

using BenchmarkDotNet.Running;
using Craftimizer.Simulator;
using Craftimizer.Simulator.Actions;
using Craftimizer.Solver.Crafty;
using ObjectLayoutInspector;
using System.Diagnostics;
namespace Craftimizer.Benchmark;
internal static class Program
{
private static void Main()
{
//var summary = BenchmarkRunner.Run<Bench>();
//return;
//TypeLayout.PrintLayout<ArenaNode<SimulationNode>>(true);
//return;
var input = new SimulationInput(
new CharacterStats {
Craftsmanship = 4041,
Control = 3905,
CP = 609,
Level = 90,
CanUseManipulation = true,
HasSplendorousBuff = true,
IsSpecialist = true,
CLvl = 560,
},
new RecipeInfo()
{
IsExpert = false,
ClassJobLevel = 90,
RLvl = 640,
ConditionsFlag = 15,
MaxDurability = 70,
MaxQuality = 14040,
MaxProgress = 6600,
QualityModifier = 70,
QualityDivider = 115,
ProgressModifier = 80,
ProgressDivider = 130,
},
0
);
var threads = 8;
var config = new SolverConfig()
{
Iterations = 30_000 / threads,
ThreadCount = threads,
};
Debugger.Break();
var s = Stopwatch.StartNew();
if (true)
_ = SolverUtils.SearchStepwise<SolverSingle>(config, input, a => Console.WriteLine(a));
else
{
(var actions, _) = SolverUtils.SearchOneshot<SolverConcurrent>(config, input);
foreach (var action in actions)
Console.Write($">{action.IntName()}");
Console.WriteLine();
}
s.Stop();
Console.WriteLine($"{s.Elapsed.TotalMilliseconds:0.00}");
Debugger.Break();
}
}