Skip to content

Commit

Permalink
Fixed: Some Singlethreaded Benchmarks, Upgrade to .NET 7
Browse files Browse the repository at this point in the history
  • Loading branch information
Sewer56 committed Oct 31, 2022
1 parent b62e4dc commit c66af5c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
Expand Down Expand Up @@ -30,7 +31,13 @@ public override void PerMethodSetup()
[Benchmark]
public int Random_ST()
{
return _scanner.FindPattern(_patterns[0]).Offset;
var result = 0;
foreach (var pattern in CollectionsMarshal.AsSpan(_patterns))
{
result = _scanner.FindPattern(_patterns[0]).Offset;
}

return result;
}

[Benchmark]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
Expand All @@ -12,7 +13,7 @@ public class RandomMtBigSize : ScannerBenchmarkBase
// 200MB, fuck Denuvo
const long ArraySize = 200_000_000;

[Params(1, 64)]
[Params(1, 4, 16, 64)]
public int NumItems;

private static List<string> _patterns;
Expand All @@ -37,13 +38,21 @@ public override void PerMethodSetup()
[Benchmark]
public int Random_ST()
{
return _scanner.FindPattern(_patterns[0]).Offset;
var result = 0;
foreach (var pattern in CollectionsMarshal.AsSpan(_patterns))
result = _scanner.FindPattern(pattern).Offset;

return result;
}

[Benchmark]
public int Random_ST_Compiled()
{
return _scanner.FindPattern_Compiled(_patterns[0]).Offset;
{
var result = 0;
foreach (var pattern in CollectionsMarshal.AsSpan(_patterns))
result = _scanner.FindPattern_Compiled(pattern).Offset;

return result;
}

[Benchmark]
Expand Down
5 changes: 3 additions & 2 deletions Reloaded.Memory.Sigscan.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,18 @@ static void Main(string[] args)
// Multithread
//BenchmarkRunner.Run<LongPatternWithMaskEndMt>(new MTSigscanConfig(LongPatternWithMaskEndMt.GetFileSize));
//BenchmarkRunner.Run<RandomMt>(new MTSigscanConfig(RandomMt.GetFileSize));
// BenchmarkRunner.Run<RandomMtBigSize>(new MTSigscanConfig(RandomMtBigSize.GetFileSize));
BenchmarkRunner.Run<RandomMtBigSize>(new MTSigscanConfig(RandomMtBigSize.GetFileSize));
// BenchmarkRunner.Run<CachedVsUncachedRandomMt>(new MTSigscanConfig(CachedVsUncachedRandomMt.GetFileSize));

BenchmarkRunner.Run<LongPatternWithMaskEnd>(ScannerBenchmarkBase.GetConfig());
// BenchmarkRunner.Run<LongPatternWithMaskEnd>(ScannerBenchmarkBase.GetConfig());
// BenchmarkRunner.Run<MediumPatternWithMaskEnd>(ScannerBenchmarkBase.GetConfig());
// BenchmarkRunner.Run<ShortPatternEnd>(ScannerBenchmarkBase.GetConfig());
// BenchmarkRunner.Run<OtherScannerBenchmarks>(ScannerBenchmarkBase.GetConfig());
// BenchmarkRunner.Run<WorstCaseScenario>(WorstCaseScenario.GetConfig());

// BenchmarkRunner.Run<ParsePattern>();
// BenchmarkRunner.Run<StringParsing>();
Console.ReadKey();
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net5.0</TargetFrameworks>
<TargetFrameworks>net7.0</TargetFrameworks>
<ProduceReferenceAssembly>true</ProduceReferenceAssembly>
<Platforms>AnyCPU;x86</Platforms>

Expand Down

0 comments on commit c66af5c

Please sign in to comment.