Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions samples/SampleApp.Uno/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ public partial class App : Application
/// </summary>
public App()
{
StartupTrace.Mark("App ctor");
this.InitializeComponent();
StartupTrace.Mark("App InitializeComponent done");
}

protected Window? MainWindow { get; private set; }
Expand All @@ -28,12 +30,14 @@ protected override async void OnLaunched(LaunchActivatedEventArgs args)
// typefaces (no flash of fallback/tofu glyphs). Registration is non-fatal: a missing
// font is logged and the grid falls back to the system default.
// See docs/uno/plan/05-fonts-and-assets.md and docs/uno/plan/06-sample-app.md §3.
StartupTrace.Mark("OnLaunched start");
await KumikoFonts.RegisterFromAppPackageAsync(new[]
{
("NotoSansJP", "ms-appx:///Assets/Fonts/NotoSansJP-Regular.ttf"),
("MaterialIcons", "ms-appx:///Assets/Fonts/MaterialIcons-Regular.ttf"),
});

StartupTrace.Mark("fonts registered");
MainWindow = new Window();
#if DEBUG
MainWindow.UseStudio();
Expand Down Expand Up @@ -63,6 +67,7 @@ await KumikoFonts.RegisterFromAppPackageAsync(new[]
MainWindow.SetWindowIcon();
// Ensure the current window is active
MainWindow.Activate();
StartupTrace.Mark("Window.Activate done");
}

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions samples/SampleApp.Uno/BasicGridPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ public sealed partial class BasicGridPage : Page

public BasicGridPage()
{
StartupTrace.Mark("BasicGridPage ctor start");
this.InitializeComponent();
StartupTrace.Mark("BasicGridPage InitializeComponent done");
DataContext = _viewModel;
LoadSampleData();
StartupTrace.Mark("BasicGridPage data loaded");

// Rows can be dragged by their handle, as on the MAUI sample's main page (the Row Drag button cycles the modes)
kumiko.ShowRowDragHandle = true;
Expand Down
1 change: 1 addition & 0 deletions samples/SampleApp.Uno/Platforms/Android/Main.Android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class Application : Microsoft.UI.Xaml.NativeApplication
{
static Application()
{
SampleApp.Uno.StartupTrace.Mark("Application static ctor");
App.InitializeLogging();
}

Expand Down
22 changes: 22 additions & 0 deletions samples/SampleApp.Uno/StartupTrace.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Diagnostics;

namespace SampleApp.Uno;

/// <summary>
/// Startup markers for cold-start measurements (#278). Each <see cref="Mark"/> writes one logcat line with the tag
/// <c>KumikoStartup</c> and the milliseconds since the process started, so <c>adb logcat -s KumikoStartup:I</c> shows
/// where the time goes. Only the Android head writes anything.
/// </summary>
internal static class StartupTrace
{
/// <summary>Logs <paramref name="name"/> with the time since the process started.</summary>
/// <param name="name">The marker name, such as <c>OnLaunched start</c>.</param>
[Conditional("__ANDROID__")]
public static void Mark(string name)
{
#if __ANDROID__
var sinceProcessStart = Android.OS.SystemClock.UptimeMillis() - Android.OS.Process.StartUptimeMillis;
Android.Util.Log.Info("KumikoStartup", $"{name} +{sinceProcessStart} ms");
#endif
}
}
Loading