diff --git a/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/JavaScript.cs b/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/JavaScript.cs index c4b39d382ab..e1bc54601bd 100644 --- a/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/JavaScript.cs +++ b/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/JavaScript.cs @@ -15,6 +15,7 @@ public class JavaScript : LanguageBase private const string _rush = "common/scripts/install-run-rush.js"; protected override Language Language => Language.JS; + private static int profileCount = 0; public override async Task<(string output, string error, object context)> SetupAsync( string project, @@ -140,6 +141,18 @@ public override async Task RunAsync( var projectDirectory = Path.Combine(WorkingDirectory, project); + if (profile) + { + // "@azure/storage-blob" -> "storage-blob" + var stripPackageName = primaryPackage.Substring(primaryPackage.LastIndexOf('/') + 1); + + var formattedArgs = arguments.Replace(" --", "_").Replace("--", "_").Replace(" ", "-"); + var profileFilename = $"{packageVersions[primaryPackage]}_{testName}_{formattedArgs}_{profileCount++}.cpuprofile"; + var profileDir = Util.GetProfileDirectory(WorkingDirectory); + var profileOutputPath = Path.GetFullPath(Path.Combine(profileDir, stripPackageName, profileFilename)); + + arguments += $" --profile --profile-path {profileOutputPath}"; + } var testResult = await Util.RunAsync("npm", $"run perf-test:node -- {testName} {arguments}", projectDirectory, outputBuilder: outputBuilder, errorBuilder: errorBuilder, throwOnError: false); diff --git a/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/Program.cs b/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/Program.cs index 797c286f938..99ef0c1e67e 100644 --- a/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/Program.cs +++ b/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/Program.cs @@ -354,8 +354,7 @@ private static async Task RunPackageVersion( test.Class, allArguments, options.Profile, - context - ); + context); } catch (Exception e) {