diff --git a/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/Net.cs b/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/Net.cs index d922857294a..9ed0956ebd8 100644 --- a/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/Net.cs +++ b/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/Net.cs @@ -101,9 +101,9 @@ public override async Task RunAsync( var dllName = Path.GetFileNameWithoutExtension(project) + ".dll"; var dllPath = Path.Combine(PublishDirectory, dllName); - var processArguments = $"{dllPath} {testName} {arguments}"; - - var result = await Util.RunAsync("dotnet", processArguments, WorkingDirectory, throwOnError: false); + var result = profile + ? await Util.RunAsync("dotnet-trace", $"collect --format NetTrace --show-child-io --output {GetProfileOutputFile(testName, arguments)} -- dotnet {dllPath} {testName} {arguments}", WorkingDirectory, throwOnError: false) + : await Util.RunAsync("dotnet", $"{dllPath} {testName} {arguments}", WorkingDirectory, throwOnError: false); // Completed 693,696 operations in a weighted-average of 1.00s (692,328.31 ops/s, 0.000 s/op) var match = Regex.Match(result.StandardOutput, @"\((.*) ops/s", RegexOptions.IgnoreCase | RegexOptions.RightToLeft); @@ -123,6 +123,12 @@ public override async Task RunAsync( }; } + private string GetProfileOutputFile(string testName, string arguments) + { + var fileName = $"{testName}_{arguments.Replace(" --", "_").Replace("--", "_").Replace(" ", "-")}_{DateTime.Now.ToString("yyyyMMdd_hhmmss")}.nettrace"; + return Path.GetFullPath(Path.Combine(Util.GetProfileDirectory(WorkingDirectory), fileName)); + } + // === Versions === // Runtime: 3.1.27 // Azure.Core: diff --git a/tools/perf-automation/tests.yml b/tools/perf-automation/tests.yml index 654814925c5..1bbb1cd9ba6 100644 --- a/tools/perf-automation/tests.yml +++ b/tools/perf-automation/tests.yml @@ -160,6 +160,13 @@ stages: - template: /eng/pipelines/templates/steps/install-dotnet.yml@azure-sdk-for-net parameters: EnableNuGetCache: false + - ${{ if parameters.Profile }}: + - task: PowerShell@2 + displayName: 'Install dotnet-trace' + inputs: + targetType: 'inline' + script: 'dotnet tool install -g dotnet-trace' + workingDirectory: '$(Build.SourcesDirectory)/sdk' ServiceDirectory: ${{ parameters.NetServiceDirectory }} PackageVersions: ${{ parameters.PackageVersions }} Tests: ${{ parameters.Tests }}