Selaa lähdekoodia

More benchmarks

Tig 9 kuukautta sitten
vanhempi
commit
7b735176f0
1 muutettua tiedostoa jossa 13 lisäystä ja 2 poistoa
  1. 13 2
      UnitTests/UICatalog/ScenarioTests.cs

+ 13 - 2
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<object []> AllScenarioTypes =>
         typeof (Scenario).Assembly
                          .GetTypes ()