Browse Source

Show app startup time in logs

pull/165/head
Ionite 1 year ago
parent
commit
863c9440a1
No known key found for this signature in database
  1. 4
      StabilityMatrix.Avalonia/Program.cs
  2. 5
      StabilityMatrix.Avalonia/ViewModels/MainWindowViewModel.cs
  3. 2
      StabilityMatrix.Core/Helper/CodeTimer.cs

4
StabilityMatrix.Avalonia/Program.cs

@ -38,12 +38,16 @@ public class Program
public static bool IsDebugBuild { get; private set; }
public static Stopwatch StartupTimer { get; } = new();
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called: things aren't initialized
// yet and stuff might break.
[STAThread]
public static void Main(string[] args)
{
StartupTimer.Start();
Args.DebugExceptionDialog = args.Contains("--debug-exception-dialog");
Args.DebugSentry = args.Contains("--debug-sentry");
Args.DebugOneClickInstall = args.Contains("--debug-one-click-install");

5
StabilityMatrix.Avalonia/ViewModels/MainWindowViewModel.cs

@ -103,6 +103,11 @@ public partial class MainWindowViewModel : ViewModelBase
Task.Run(() => settingsManager.IndexCheckpoints()).SafeFireAndForget();
PreloadPages();
Program.StartupTimer.Stop();
var startupTime = CodeTimer.FormatTime(Program.StartupTimer.Elapsed);
Logger.Info($"App started ({startupTime})");
if (Program.Args.DebugOneClickInstall || !settingsManager.Settings.InstalledPackages.Any())
{
var viewModel = dialogFactory.Get<OneClickInstallViewModel>();

2
StabilityMatrix.Core/Helper/CodeTimer.cs

@ -52,7 +52,7 @@ public class CodeTimer : IDisposable
/// <summary>
/// Formats a TimeSpan into a string. Chooses the most appropriate unit of time.
/// </summary>
private static string FormatTime(TimeSpan duration)
public static string FormatTime(TimeSpan duration)
{
if (duration.TotalSeconds < 1)
{

Loading…
Cancel
Save