Skip to content

Commit

Permalink
Added logging for how long processes spawned by uninstaller factories…
Browse files Browse the repository at this point in the history
… run; #248
  • Loading branch information
Klocman committed Jan 23, 2020
1 parent 08c05d0 commit d8b4e78
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion source/UninstallTools/Factory/ChocolateyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,13 @@ private static string StartProcessAndReadOutput(string filename, string args)
RedirectStandardError = false,
CreateNoWindow = true,
StandardOutputEncoding = Encoding.Default
})) return process?.StandardOutput.ReadToEnd();
}))
{
var sw = Stopwatch.StartNew();
var output = process?.StandardOutput.ReadToEnd();
Console.WriteLine($"[Performance] Running command {filename} {args} took {sw.ElapsedMilliseconds}ms");
return output;
}
}
}
}
2 changes: 2 additions & 0 deletions source/UninstallTools/Factory/FactoryTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ internal static string StartHelperAndReadOutput(string filename, string args)
{
try
{
var sw = Stopwatch.StartNew();
var output = process?.StandardOutput.ReadToEnd();
Console.WriteLine($"[Performance] Running command {filename} {args} took {sw.ElapsedMilliseconds}ms");
return process?.ExitCode == 0 ? output : null;
}
catch (Win32Exception ex)
Expand Down
7 changes: 6 additions & 1 deletion source/UninstallTools/Factory/ScoopFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ private static string RunScoopCommand(string scoopArgs)
startInfo.StandardOutputEncoding = Encoding.Default;

using (var process = Process.Start(startInfo))
return process?.StandardOutput.ReadToEnd();
{
var sw = Stopwatch.StartNew();
var output = process?.StandardOutput.ReadToEnd();
Console.WriteLine($"[Performance] Running command {startInfo.FileName} {startInfo.Arguments} took {sw.ElapsedMilliseconds}ms");
return output;
}
}

private static ProcessStartCommand MakeScoopCommand(string scoopArgs)
Expand Down

0 comments on commit d8b4e78

Please sign in to comment.