Add performance tracing
This commit is contained in:
parent
563f6497fd
commit
36e56e9d00
12 changed files with 348 additions and 50 deletions
|
@ -42,17 +42,33 @@ namespace Microsoft.DotNet.Cli
|
|||
{
|
||||
DebugHelper.HandleDebugSwitch(ref args);
|
||||
|
||||
if (Env.GetEnvironmentVariableAsBool("DOTNET_CLI_CAPTURE_TIMING", false))
|
||||
{
|
||||
PerfTrace.Enabled = true;
|
||||
}
|
||||
|
||||
InitializeProcess();
|
||||
|
||||
try
|
||||
{
|
||||
return Program.ProcessArgs(args, new Telemetry());
|
||||
using (PerfTrace.Current.CaptureTiming())
|
||||
{
|
||||
return ProcessArgs(args, new Telemetry());
|
||||
}
|
||||
}
|
||||
catch (GracefulException e)
|
||||
{
|
||||
Console.WriteLine(e.Message.Red().Bold());
|
||||
return 1;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (PerfTrace.Enabled)
|
||||
{
|
||||
Reporter.Output.WriteLine("Performance Summary:");
|
||||
PerfTraceOutput.Print(Reporter.Output, PerfTrace.GetEvents());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static int ProcessArgs(string[] args, ITelemetry telemetryClient)
|
||||
|
@ -107,6 +123,7 @@ namespace Microsoft.DotNet.Cli
|
|||
if (verbose.HasValue)
|
||||
{
|
||||
Environment.SetEnvironmentVariable(CommandContext.Variables.Verbose, verbose.ToString());
|
||||
Console.WriteLine($"Telemetry is: {(telemetryClient.Enabled ? "Enabled" : "Disabled")}");
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(command))
|
||||
|
@ -141,6 +158,7 @@ namespace Microsoft.DotNet.Cli
|
|||
|
||||
}
|
||||
|
||||
|
||||
private static void InitializeProcess()
|
||||
{
|
||||
// by default, .NET Core doesn't have all code pages needed for Console apps.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue