Skip to content

Instantly share code, notes, and snippets.

@spetroll
Created September 15, 2011 08:38
Show Gist options
  • Save spetroll/1218833 to your computer and use it in GitHub Desktop.
Save spetroll/1218833 to your computer and use it in GitHub Desktop.
public static void Main(String[] args)
{
Console.WriteLine("\n\nStarting Test");
var evals = new List<EvaluationResult>
{
StartNewTest("PST", new PSTLooper(intHands), RUNS),
StartNewTest("SteveBrecher", new SteveBrecherLooper(longHands), RUNS),
StartNewTest("2p2", new TwoPlusTwoLooper(intHands), RUNS)
};
foreach (var e in evals)
{
ulong sum = 0;
Console.WriteLine("{0,20}: {1,10:0.00} H/s {2,7}ms", e.Description,
sum / e.Timer.Elapsed.TotalSeconds / 1000000, e.Timer.ElapsedMilliseconds);
}
Console.Read();
}
private static EvaluationResult StartNewTest(string description, IEvaluator e, int runs)
{
long[][] handTypeSum =
Enumerable.Range(0, Environment.ProcessorCount).Select(x => new long[handDescriptions.Length]).ToArray();
var watch = Stopwatch.StartNew();
Parallel.For(0, Environment.ProcessorCount,
i => { handTypeSum[i] = e.EvalEnumeration(i); });
watch.Stop();
var totalTypeSum = new long[handDescriptions.Count()];
for (int i = 0; i < Environment.ProcessorCount; i++)
{
for (int j = 0; j < handDescriptions.Count(); j++)
{
totalTypeSum[j] += handTypeSum[i][j];
}
}
return new EvaluationResult(description, watch, totalTypeSum);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment