mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-08 03:27:04 +09:00

* Create markdownlint.yml * Create markdownlint-problem-matcher.json * Create .markdownlint.json * Update .markdownlint.json * fix violations * fixes * Remove "push" section As advised by @viktorhofer so it's quite clear it only runs in CI. Co-authored-by: Dan Moseley <danmose@microsoft.com>
2.1 KiB
2.1 KiB
How to run a sample app with AOT profiling enabled
Setting up a project with profiling
- Define a
write_at
method. By default it is:
[MethodImpl(MethodImplOptions.NoInlining)]
public static void StopProfile(){}
- Initialize the profiler in the main javascript (e.g. runtime.js)
var Module = {
onRuntimeInitialized: function () {
...
if (config.enable_profiler)
{
config.aot_profiler_options = {
write_at: "<Namespace.Class::StopProfile>",
send_to: "System.Runtime.InteropServices.JavaScript.Runtime::DumpAotProfileData"
}
}
- Call the
write_at
method at the end of the app, either in C# or in JS. To call thewrite_at
method in JS, make use of bindings:
BINDING.call_static_method("<[ProjectName] Namespace.Class::StopProfile">, []);
When the write_at
method is called, the send_to
method DumpAotProfileData
stores the profile data into Module.aot_profile_data
- Download
Module.aot_profile_data
in JS, using something similar to:
function saveProfile() {
var a = document.createElement('a');
var blob = new Blob([Module.aot_profile_data]);
a.href = URL.createObjectURL(blob);
a.download = "data.aotprofile";
// Append anchor to body.
document.body.appendChild(a);
a.click();
// Remove anchor from body
document.body.removeChild(a);
}
Build and Run a project with profiling
- To enable profiling during a build, we need to make use of WasmApp.InTree.targets/props by importing into the project file:
<Import Project="$(MonoProjectRoot)\wasm\build\WasmApp.InTree.targets" />
<Import Project="$(MonoProjectRoot)wasm\build\WasmApp.InTree.props" />
For more information on how to utilize WasmApp.InTree.targets/props consult the wasm build directory README.md
- To get the profile data, run:
make get-aot-profile
Which will build and run the current project with AOT disabled and the AOT profiler enabled.
-
Go to localhost:8000 and the profile will automatically download.
-
To use the profile data in the project, run:
make use-aot-profile PROFILE_PATH=<path to profile file>