Added process priority and affinity for v2 benchmarks

pull/288/head
csharptest 14 years ago committed by rogerk
parent c671a4b317
commit 0e2d144eb6
  1. 19
      src/ProtoBench/Program.cs

@ -67,12 +67,18 @@ namespace Google.ProtocolBuffers.ProtoBench
RunBenchmark = BenchmarkV1; RunBenchmark = BenchmarkV1;
if (temp.Remove("/v2") || temp.Remove("-v2")) if (temp.Remove("/v2") || temp.Remove("-v2"))
RunBenchmark = BenchmarkV2; {
string cpu = temp.Find(x => x.StartsWith("-cpu:"));
int cpuIx = 1;
if (cpu != null) cpuIx = 1 << Math.Max(0, int.Parse(cpu.Substring(5)));
//pin the entire process to a single CPU
Process.GetCurrentProcess().ProcessorAffinity = new IntPtr(cpuIx);
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime;
RunBenchmark = BenchmarkV2;
}
args = temp.ToArray(); args = temp.ToArray();
if (args.Length < 2 || (args.Length%2) != 0) if (args.Length < 2 || (args.Length%2) != 0)
{ {
Console.Error.WriteLine("Usage: ProtoBench [/fast] <descriptor type name> <input data>"); Console.Error.WriteLine("Usage: ProtoBench [/fast] <descriptor type name> <input data>");
@ -188,13 +194,6 @@ namespace Google.ProtocolBuffers.ProtoBench
double bps = (iterations * dataSize) / (cycle.TotalSeconds * 1024 * 1024); double bps = (iterations * dataSize) / (cycle.TotalSeconds * 1024 * 1024);
if (Verbose) Console.WriteLine("Round {0,3}: Count = {1,6}, Bps = {2,8:f3}", runs, iterations, bps); if (Verbose) Console.WriteLine("Round {0,3}: Count = {1,6}, Bps = {2,8:f3}", runs, iterations, bps);
if (runs == 0 && bps > first * 1.1)
{
if (Verbose) Console.WriteLine("Warming up...");
iterations = (int)((target.Ticks * iterations) / (double)cycle.Ticks);
first = bps;
continue;//still warming up...
}
best = Math.Max(best, bps); best = Math.Max(best, bps);
worst = Math.Min(worst, bps); worst = Math.Min(worst, bps);

Loading…
Cancel
Save