Skip to content

Commit

Permalink
[JS] Capture profiling artifacts (#5369)
Browse files Browse the repository at this point in the history
* set profiling arguments

* add a space

* testing

* more testing

* formatting

* remove logs

* serviceLanguageInfo.Project testing

* remove console.logs

* testing

* ILanguage fix

* LanguageBase update

* build fixes

* delete unneeded dependency

* strip package name

* remove console logs

* profileOutputPath

* Update tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/JavaScript.cs

* Update tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/JavaScript.cs

Co-authored-by: Mike Harder <[email protected]>

* Update tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/JavaScript.cs

* address feedback

* remove i

* Update tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/JavaScript.cs

Co-authored-by: Mike Harder <[email protected]>

* strip package name

* add arguments in the name of the profile generated

* Fix formatting

* Remove unnecessary using

* Remove whitespace

* Improve formatting

* Code cleanup

* .TrimEnd(" ")

* default is space for trimend

* " --" -> "_"

* .Replace(" --", "_").Replace("--", "_").

---------

Co-authored-by: Harsha Nalluru <@[email protected]>
Co-authored-by: Mike Harder <[email protected]>
  • Loading branch information
3 people authored Feb 21, 2023
1 parent 0ecf2fe commit dfa253e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 13 additions & 0 deletions tools/perf-automation/Azure.Sdk.Tools.PerfAutomation/JavaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -140,6 +141,18 @@ public override async Task<IterationResult> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ private static async Task RunPackageVersion(
test.Class,
allArguments,
options.Profile,
context
);
context);
}
catch (Exception e)
{
Expand Down

0 comments on commit dfa253e

Please sign in to comment.