Skip to content

Commit

Permalink
Merge b1676af into a6a5c53
Browse files Browse the repository at this point in the history
  • Loading branch information
VJalili committed Sep 15, 2022
2 parents a6a5c53 + b1676af commit b47819d
Show file tree
Hide file tree
Showing 3 changed files with 609 additions and 5 deletions.
19 changes: 16 additions & 3 deletions Benchmark/PerformanceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public static void Test(string dataDir, string resultsFilename, string version,
timer.Restart();
var results = new List<Result>();
var msg = $"\t[{++counter}/{cases.Count}]\tBenchmarking using {c.Key}: ... ";
Console.ForegroundColor = ConsoleColor.Green;
Console.Write(msg);
Console.ResetColor();
var reps = SyntheticReps.Generate(c.Value, maxRepCount);
var syntheticReps = reps.Except(c.Value).ToList();

Expand All @@ -45,15 +47,19 @@ public static void Test(string dataDir, string resultsFilename, string version,

results.Add(result);

Console.ForegroundColor = ConsoleColor.Green;
Console.Write($"\r{msg}{Math.Floor((i - minRepCount) / (double)(maxRepCount - minRepCount) * 100)}%");
Console.ResetColor();
}

foreach (var syntheticRep in syntheticReps)
File.Delete(syntheticRep);
if (verInfo.OutputDir != null)
Directory.Delete(verInfo.OutputDir, true);
timer.Stop();
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"\r{msg}Done!\t(ET: {timer.Elapsed}");
Console.ResetColor();

var writer = new StreamWriter(resultsFilename, append: true);
foreach (var result in results)
Expand All @@ -66,8 +72,15 @@ private static Result MeasurePerformance(ProcessStartInfo info, int waitToExitIn
{
var result = new Result();

info.UseShellExecute = false;
info.RedirectStandardOutput = true;
// Do not enable redirecting stdout.
// Because some older versions of MSPC write messages to
// console in a way that cause the console to exit, hence
// this processes assumes it as MSPC has finished processing
// data, while in fact, all MSPC did was print a message
// in a particular way.
//
// info.UseShellExecute = false
// info.RedirectStandardOutput = true

using (var process = Process.Start(info))
{
Expand All @@ -94,7 +107,7 @@ private static Result MeasurePerformance(ProcessStartInfo info, int waitToExitIn
// usage information will throw this error.
}

process.StandardOutput.ReadToEnd();
// process.StandardOutput.ReadToEnd()
}
}
while (!process.WaitForExit(waitToExitInMilliseconds));
Expand Down
Loading

0 comments on commit b47819d

Please sign in to comment.