mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-27 00:07:58 +01:00
Added stopwatch
This commit is contained in:
@@ -198,10 +198,16 @@ public static partial class Application // Initialization (Init/Shutdown)
|
||||
public static void Shutdown ()
|
||||
{
|
||||
// TODO: Throw an exception if Init hasn't been called.
|
||||
|
||||
bool wasInitialized = IsInitialized;
|
||||
ResetState ();
|
||||
PrintJsonErrors ();
|
||||
bool init = IsInitialized;
|
||||
InitializedChanged?.Invoke (null, new (in init));
|
||||
|
||||
if (wasInitialized)
|
||||
{
|
||||
bool init = IsInitialized;
|
||||
InitializedChanged?.Invoke (null, new (in init));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Text.Json.Serialization;
|
||||
using Terminal.Gui;
|
||||
using UICatalog.Scenarios;
|
||||
using static Terminal.Gui.ConfigurationManager;
|
||||
using Command = Terminal.Gui.Command;
|
||||
using RuntimeEnvironment = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment;
|
||||
@@ -337,6 +338,14 @@ public class UICatalogApp
|
||||
Apply ();
|
||||
scenario.Theme = _cachedTheme;
|
||||
scenario.TopLevelColorScheme = _topLevelColorScheme;
|
||||
|
||||
#if DEBUG_IDISPOSABLE
|
||||
// Measure how long it takes for the app to shut down
|
||||
var sw = new Stopwatch ();
|
||||
string scenarioName = scenario.GetName ();
|
||||
Application.InitializedChanged += ApplicationOnInitializedChanged;
|
||||
#endif
|
||||
|
||||
scenario.Main ();
|
||||
scenario.Dispose ();
|
||||
|
||||
@@ -345,10 +354,31 @@ public class UICatalogApp
|
||||
// TODO: Throw if shutdown was not called already
|
||||
Application.Shutdown ();
|
||||
VerifyObjectsWereDisposed ();
|
||||
|
||||
#if DEBUG_IDISPOSABLE
|
||||
Application.InitializedChanged -= ApplicationOnInitializedChanged;
|
||||
|
||||
void ApplicationOnInitializedChanged (object? sender, EventArgs<bool> e)
|
||||
{
|
||||
if (e.CurrentValue)
|
||||
{
|
||||
sw.Start ();
|
||||
}
|
||||
else
|
||||
{
|
||||
sw.Stop ();
|
||||
Debug.WriteLine ($"Shutdown of {scenarioName} Scenario took {sw.ElapsedMilliseconds}ms");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
StopConfigFileWatcher ();
|
||||
VerifyObjectsWereDisposed ();
|
||||
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void VerifyObjectsWereDisposed ()
|
||||
|
||||
Reference in New Issue
Block a user