I am creating a universal Windows application (UWP) using the Visual C # Blank App template in Visual Studio. I want to measure two data points at application startup:
- How long does it take for the user interface to be completely updated after creating / modifying the XAML element?
- How long does it take a program to process XAML elements internally, regardless of whether changes are reflected in the user interface?
For the first point , let's say I create an application that has 5 ToggleSwitches defined as XAML in MainPage.xaml. I want to measure how long it takes for the user interface to display all 5 ToggleSwitches. I set the stopwatch timer right in front of this .InitializeComponent () command in MainPage.xaml.cs (since I assume this is where the processing of Designer XAML elements begins). I want to stop the timer as soon as the window is drawn correctly. I experimented with the Loaded and LayoutUpdated events for the XAML element, but none of them fire when the user interface is updated. Where can I put my timer to get the data I'm looking for? If I go through the code in the debugger, in which line of code does “Step Over” cause the user interface to be updated?
For the second point, I just want to record how much time the computer takes to process the XAML code internally (not including displaying the user interface, starting the linking mechanism, processing with Direct3D — it's just XAML processing). My first instinct was to simply start the stopwatch before that. Initialize Component () and finish immediately. However, I do not see changes in the data based on the content of the page. For example, if I run my application with 100 ToggleSwitches or 5 ToggleSwitches defined in XAML Designer, this.InitializeComponent () method takes the same amount of time. Any ideas how I can better measure this data point?
Any help is greatly appreciated.
source share