Benchmarks for heuristic combined methods added
This commit is contained in:
1 parent
880b1cd962
commit
3147728d5b
1 file changed
+37
@@ -12,6 +12,7 @@ namespace EvenPerfectBitScanner.Benchmarks;
|
|||||||
[MemoryDiagnoser]
|
[MemoryDiagnoser]
|
||||||
public class PrimeTesterBenchmarks
|
public class PrimeTesterBenchmarks
|
||||||
{
|
{
|
||||||
|
private static readonly HeuristicCombinedPrimeTester _heuristicCombinedTester = new();
|
||||||
private static readonly HeuristicPrimeTester _heuristicTester = new();
|
private static readonly HeuristicPrimeTester _heuristicTester = new();
|
||||||
private ulong[] _candidates = [];
|
private ulong[] _candidates = [];
|
||||||
|
|
||||||
@@ -71,6 +72,42 @@ public class PrimeTesterBenchmarks
|
|||||||
return primeCount;
|
return primeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Benchmark]
|
||||||
|
public int HeuristicCombinedGpu()
|
||||||
|
{
|
||||||
|
HeuristicCombinedPrimeTester tester = _heuristicCombinedTester;
|
||||||
|
ulong[] values = _candidates;
|
||||||
|
int primeCount = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < values.Length; i++)
|
||||||
|
{
|
||||||
|
if (HeuristicCombinedPrimeTester.IsPrimeGpu(values[i]))
|
||||||
|
{
|
||||||
|
primeCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return primeCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Benchmark]
|
||||||
|
public int HeuristicCombinedCpu()
|
||||||
|
{
|
||||||
|
HeuristicCombinedPrimeTester tester = _heuristicCombinedTester;
|
||||||
|
ulong[] values = _candidates;
|
||||||
|
int primeCount = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < values.Length; i++)
|
||||||
|
{
|
||||||
|
if (HeuristicCombinedPrimeTester.IsPrimeCpu(values[i]))
|
||||||
|
{
|
||||||
|
primeCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return primeCount;
|
||||||
|
}
|
||||||
|
|
||||||
private static readonly PrimeTester _nonHeuristicTester = new();
|
private static readonly PrimeTester _nonHeuristicTester = new();
|
||||||
|
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
|
|||||||
Reference in new issue
Block a user