Reuse heuristic prime order config across runtime

This commit is contained in:
Marek Lemańczyk committed 2025-10-20 00:51:10 +02:00
1 parent d99610098a
commit e9cff7bfcd
2 files changed
+10 -1

No files matched your search

+9 -1
View File
@@ -10,15 +10,23 @@ internal static partial class PrimeOrderCalculator
internal readonly struct PrimeOrderSearchConfig(uint smallFactorLimit, int pollardRhoMilliseconds, int maxPowChecks, PrimeOrderMode mode)
{
private static PrimeOrderSearchConfig _heuristicDefault = CreateHeuristicDefault(UnboundedTaskScheduler.ConfiguredThreadCount);
public static PrimeOrderSearchConfig HeuristicDefault
{
get
{
return CreateHeuristicDefault(UnboundedTaskScheduler.ConfiguredThreadCount);
return _heuristicDefault;
}
}
public static readonly PrimeOrderSearchConfig StrictDefault = new(smallFactorLimit: 1_000_000, pollardRhoMilliseconds: 0, maxPowChecks: 0, PrimeOrderMode.Strict);
public static void ConfigureHeuristicDefault(int threadCount)
{
_heuristicDefault = CreateHeuristicDefault(threadCount);
}
public static PrimeOrderSearchConfig CreateHeuristicDefault(int threadCount)
{
int normalizedThreadCount = threadCount < 1 ? 1 : threadCount;