-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] Add targets for AOT profiling (#3964)
Fixes: #3792 Context: #3740 Context: #3963 Add the following targets to simplify Profiled AOT usage: * `BuildAndStartAotProfiling` * `FinishAotProfiling` The `BuildAndStartAotProfiling` target builds an Application `.csproj` with the AOT profiler embedded into the `.apk`, installs the `.apk`, sets the AOT profiler socket port to `$(AndroidAotProfilerPort)`, and starts the *launch* Activity on the target device. `$(AndroidAotProfilerPort)` defaults to port 9999. The `FinishAotProfiling` target attaches to the `$(AndroidAotProfilerPort)` port, collects the AOT profiler data from the target device, and writes the collected data into `$(AndroidAotCustomProfilePath)`. `$(AndroidAotCustomProfilePath)` defaults to `custom.aprof`. The use of these two targets allows easily launching an Activity, waiting for a period of time -- so that process startup can complete, or so that some set of application behaviors can be included into the profiled data -- and then collecting the profile.
- Loading branch information
1 parent
83cd391
commit 853b367
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
### Add new AOT profiling targets | ||
|
||
The new `BuildAndStartAotProfiling` target builds the package with | ||
embedded AOT profiler, sets AOT profiler socket port to | ||
`$(AndroidAotProfilerPort)` and starts the *launch* activity. | ||
|
||
The new `FinishAotProfiling` target collects the AOT profiler data | ||
from the device or the emulator through sockets port | ||
`$(AndroidAotProfilerPort)` and writes them to | ||
`$(AndroidAotCustomProfilePath)`. | ||
|
||
The default values for port and custom profile are `9999` and | ||
`custom.aprof`. | ||
|
||
The `aprofutil` call may be extended with | ||
`$(AProfUtilExtraOptions)`, to pass additional options. | ||
|
||
This is equivalent to: | ||
|
||
aprofutil $(AProfUtilExtraOptions) -s -v -f -p $(AndroidAotProfilerPort) -o "$(AndroidAotCustomProfilePath)" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using NUnit.Framework; | ||
using System.IO; | ||
using Xamarin.ProjectTools; | ||
|
||
namespace Xamarin.Android.Build.Tests | ||
{ | ||
public class AotProfileTests : DeviceTest | ||
{ | ||
|
||
[Test] | ||
public void BuildBasicApplicationAndAotProfileIt () | ||
{ | ||
if (!HasDevices) | ||
Assert.Ignore ("Skipping test. No devices available."); | ||
|
||
var proj = new XamarinAndroidApplicationProject () { IsRelease = true }; | ||
proj.SetProperty (KnownProperties.AndroidSupportedAbis, "armeabi-v7a;x86"); | ||
var projDirectory = Path.Combine ("temp", TestName); | ||
using (var b = CreateApkBuilder (projDirectory)) { | ||
Assert.IsTrue (b.RunTarget (proj, "BuildAndStartAotProfiling"), "Run of BuildAndStartAotProfiling should have succeeded."); | ||
System.Threading.Thread.Sleep (5000); | ||
b.BuildLogFile = "build2.log"; | ||
Assert.IsTrue (b.RunTarget (proj, "FinishAotProfiling", doNotCleanupOnUpdate: true), "Run of FinishAotProfiling should have succeeded."); | ||
var customProfile = Path.Combine (Root, projDirectory, "custom.aprof"); | ||
FileAssert.Exists (customProfile); | ||
} | ||
} | ||
} | ||
} |