Remove ref passing, but keep devirtualizations

This commit is contained in:
Asriel Camora
2024-03-16 13:24:26 -07:00
parent 3223bdcbfb
commit ec77f1d021
48 changed files with 411 additions and 787 deletions
+21 -5
View File
@@ -1,4 +1,5 @@
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Diagnostics.dotTrace;
using BenchmarkDotNet.Jobs;
using Craftimizer.Simulator;
@@ -6,10 +7,12 @@ using Craftimizer.Solver;
namespace Craftimizer.Benchmark;
[SimpleJob(RuntimeMoniker.Net70, baseline: true)]
[SimpleJob(RuntimeMoniker.Net80)]
[SimpleJob(RuntimeMoniker.Net70)]
[SimpleJob(RuntimeMoniker.Net80, baseline: true)]
[MinColumn, Q1Column, Q3Column, MaxColumn]
[DotTraceDiagnoser]
//[DotTraceDiagnoser]
[MemoryDiagnoser]
[DisassemblyDiagnoser(maxDepth: 500, exportGithubMarkdown: false, exportHtml: true)]
public class Bench
{
public record struct HashWrapper<T>(T Data) where T : notnull
@@ -95,12 +98,25 @@ public class Bench
[ParamsSource(nameof(Configs))]
public HashWrapper<SolverConfig> Config { get; set; }
[Benchmark]
public async Task<float> Solve()
// [Benchmark]
public async Task<float> SolveAsync()
{
var solver = new Solver.Solver(Config, State);
solver.Start();
var (_, s) = await solver.GetTask().ConfigureAwait(false);
return (float)s.Quality / s.Input.Recipe.MaxQuality;
}
[Benchmark]
public (float MaxScore, SolverSolution Solution) Solve()
{
var config = new MCTSConfig(Config.Data);
var solver = new MCTS(config, State);
var progress = 0;
solver.Search(Config.Data.Iterations, ref progress, CancellationToken.None);
var solution = solver.Solution();
return (solver.MaxScore, solution);
}
}