using System.IO; using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Engines; using ParadoxSaveParser.Lib; namespace ParadoxSaveParser.Benchmarks; /// /// 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 MemoryStream copy in /// to see what that copy buys. /// [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); } }