added benchmarks

This commit is contained in:
2026-09-14 23:09:25 +02:00
parent f1aca261ae
commit 3dde5e5acf
11 changed files with 823 additions and 18 deletions
@@ -0,0 +1,29 @@
using System.IO;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
using ParadoxSaveParser.Lib;
namespace ParadoxSaveParser.Benchmarks;
/// <summary>
/// SearchExpression only, parsing straight from the save file on disk:
/// the file is opened inside the benchmark and is never preloaded into a byte[].
/// Run it once with and once without the internal <c>MemoryStream</c> copy in
/// <see cref="SaveParserEU4" /> to see what that copy buys.
/// </summary>
[MemoryDiagnoser]
[SimpleJob(RunStrategy.Monitoring, launchCount: 1, warmupCount: 1, iterationCount: 5)]
public class ParserInputBenchmarks
{
private ISearchExpression _query = null!;
[GlobalSetup]
public void Setup() => _query = SearchExpressionCompiler.Compile(BenchData.PdxQuery);
[Benchmark(Description = "SearchExpression over FileStream")]
public long FromFile()
{
using var file = File.OpenRead(BenchData.PdxPath);
return Extractors.SearchExpressionFromStream(file, _query);
}
}