public DetermineWorkload(int threads, int workloadSize)
{
_workloadSize = workloadSize;
if (threads == 0)
{
#if !SILVERLIGHT
var num = (int) (Math.Log(((int) Process.GetCurrentProcess().ProcessorAffinity + 1), 2));
#else
int num = 4;
#endif
// if there is more than one processor, use processor count +1
if (num != 1)
{
num++;
}
// if there is a single processor, just use one thread
// Now see how big the training sets are going to be.
// We want at least 100 training elements in each.
// This method will likely be further "tuned" in future versions.
long recordCount = _workloadSize;
long workPerThread = recordCount/num;
if (workPerThread < 100)
{
num = Math.Max(1, (int) (recordCount/100));
}
_threadCount = num;
}
else
{
_threadCount = Math.Min(threads, workloadSize);
}
}