From 7b735176f0f8d981cda40dab602ffecf61b77162 Mon Sep 17 00:00:00 2001 From: Tig Date: Thu, 24 Oct 2024 14:07:52 -0600 Subject: [PATCH] More benchmarks --- UnitTests/UICatalog/ScenarioTests.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/UnitTests/UICatalog/ScenarioTests.cs b/UnitTests/UICatalog/ScenarioTests.cs index 96dc9c14c..f8a9e3cb6 100644 --- a/UnitTests/UICatalog/ScenarioTests.cs +++ b/UnitTests/UICatalog/ScenarioTests.cs @@ -157,6 +157,7 @@ public class ScenarioTests : TestsAllViews int clearedContentCount = 0; int refreshedCount = 0; int updatedCount = 0; + int drawCompleteCount = 0; _output.WriteLine ($"Running Scenario '{scenarioType}'"); var scenario = (Scenario)Activator.CreateInstance (scenarioType); @@ -178,6 +179,8 @@ public class ScenarioTests : TestsAllViews _output.WriteLine ($" called Driver.ClearContents {clearedContentCount} times."); _output.WriteLine ($" called Driver.Refresh {refreshedCount} times."); _output.WriteLine ($" which updated the screen {updatedCount} times."); + _output.WriteLine ($" called Application.Top.Draw {drawCompleteCount} times."); +// _output.WriteLine ($" called View.Draw {drawCompleteCount} times."); // Restore the configuration locations ConfigurationManager.Locations = savedConfigLocations; @@ -200,11 +203,13 @@ public class ScenarioTests : TestsAllViews updatedCount++; } }; + Application.NotifyNewRunState += OnApplicationNotifyNewRunState; stopwatch = Stopwatch.StartNew (); } else { + Application.NotifyNewRunState -= OnApplicationNotifyNewRunState; Application.Iteration -= OnApplicationOnIteration; stopwatch!.Stop (); } @@ -214,16 +219,22 @@ public class ScenarioTests : TestsAllViews void OnApplicationOnIteration (object s, IterationEventArgs a) { iterationCount++; - if (iterationCount > 5000) + if (iterationCount > 1000) { // Press QuitKey _output.WriteLine ($"Attempting to quit with {Application.QuitKey}"); Application.RaiseKeyDownEvent (Application.QuitKey); } } - } + void OnApplicationNotifyNewRunState (object sender, RunStateEventArgs e) + { + Application.Top.DrawComplete += (sender, args) => drawCompleteCount++; + } + + } + public static IEnumerable AllScenarioTypes => typeof (Scenario).Assembly .GetTypes ()