added benchmarks
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user