ContentPagePerformancePage.xaml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. x:Class="ControlCatalog.Pages.ContentPagePerformancePage">
  4. <Grid ColumnDefinitions="*,300">
  5. <!-- Left: NavigationPage + log -->
  6. <DockPanel Grid.Column="0" Margin="16">
  7. <TextBlock DockPanel.Dock="Top"
  8. Text="Push pages of varying weight and observe how GC reclaims memory after pop."
  9. FontSize="13" Opacity="0.6" Margin="0,0,0,12" />
  10. <DockPanel DockPanel.Dock="Bottom" Margin="0,12,0,0" Height="140">
  11. <DockPanel DockPanel.Dock="Top" Margin="0,0,0,4">
  12. <TextBlock Text="Operation Log" FontSize="13" FontWeight="SemiBold"
  13. VerticalAlignment="Center" />
  14. <Button x:Name="ClearLogButton" Content="Clear" FontSize="11"
  15. Padding="8,2" HorizontalAlignment="Right" Click="OnClearLog" />
  16. </DockPanel>
  17. <Border BorderBrush="{DynamicResource SystemControlForegroundBaseMediumLowBrush}"
  18. BorderThickness="1" CornerRadius="4" ClipToBounds="True">
  19. <ScrollViewer x:Name="LogScrollViewer">
  20. <StackPanel x:Name="LogPanel" Spacing="0" />
  21. </ScrollViewer>
  22. </Border>
  23. </DockPanel>
  24. <Border BorderBrush="{DynamicResource SystemControlForegroundBaseMediumLowBrush}"
  25. BorderThickness="1" CornerRadius="8" ClipToBounds="True">
  26. <NavigationPage x:Name="NavPage">
  27. <NavigationPage.Resources>
  28. <SolidColorBrush x:Key="NavigationBarBackground" Color="Transparent" />
  29. </NavigationPage.Resources>
  30. </NavigationPage>
  31. </Border>
  32. </DockPanel>
  33. <!-- Right: dashboard -->
  34. <Border Grid.Column="1"
  35. BorderBrush="{DynamicResource SystemControlForegroundBaseMediumLowBrush}"
  36. BorderThickness="1,0,0,0"
  37. Padding="16">
  38. <ScrollViewer>
  39. <StackPanel Spacing="12">
  40. <TextBlock Text="Metrics" FontSize="16" FontWeight="SemiBold"
  41. Foreground="{DynamicResource SystemControlHighlightAccentBrush}" />
  42. <TextBlock x:Name="StackDepthText" Text="Stack Depth: 0" FontSize="13" />
  43. <TextBlock x:Name="LiveInstancesText" Text="Live Page Instances: 0" FontSize="13" />
  44. <TextBlock x:Name="TotalCreatedText" Text="Total Pages Created: 0" FontSize="13" />
  45. <DockPanel>
  46. <TextBlock x:Name="ManagedMemoryText" Text="Managed Heap: 0.0 MB" FontSize="13" />
  47. <TextBlock x:Name="MemoryDeltaText" Text="" FontSize="13"
  48. FontWeight="SemiBold" Margin="6,0,0,0" />
  49. </DockPanel>
  50. <Separator Margin="0,4" />
  51. <TextBlock Text="Content Weight" FontSize="16" FontWeight="SemiBold"
  52. Foreground="{DynamicResource SystemControlHighlightAccentBrush}" />
  53. <ComboBox x:Name="WeightCombo" HorizontalAlignment="Stretch" SelectedIndex="0">
  54. <ComboBoxItem Content="Lightweight (~50 KB)" />
  55. <ComboBoxItem Content="Moderate (~500 KB)" />
  56. <ComboBoxItem Content="Heavy (~2 MB)" />
  57. </ComboBox>
  58. <TextBlock Text="Sets the memory allocated by each new page. Push pages, pop them, then Force GC to see the heap drop."
  59. TextWrapping="Wrap" FontSize="11" Opacity="0.6" />
  60. <Separator Margin="0,4" />
  61. <TextBlock Text="Actions" FontSize="16" FontWeight="SemiBold"
  62. Foreground="{DynamicResource SystemControlHighlightAccentBrush}" />
  63. <Button x:Name="PushButton" Content="Push Page" HorizontalAlignment="Stretch" Click="OnPush" />
  64. <Button x:Name="Push5Button" Content="Push 5 Pages" HorizontalAlignment="Stretch" Click="OnPush5" />
  65. <Button x:Name="PopButton" Content="Pop Page" HorizontalAlignment="Stretch" Click="OnPop" />
  66. <Button x:Name="PopToRootButton" Content="Pop to Root" HorizontalAlignment="Stretch" Click="OnPopToRoot" />
  67. <Separator Margin="0,4" />
  68. <Button x:Name="ForceGCButton" Content="Force GC + Refresh"
  69. HorizontalAlignment="Stretch" Click="OnForceGC"
  70. Background="{DynamicResource SystemControlHighlightAccentBrush}"
  71. Foreground="White" />
  72. <CheckBox x:Name="AutoRefreshCheck" Content="Auto-refresh (2s)"
  73. FontSize="13" IsCheckedChanged="OnAutoRefreshChanged" />
  74. <Separator Margin="0,4" />
  75. <TextBlock Text="Stack" FontSize="16" FontWeight="SemiBold"
  76. Foreground="{DynamicResource SystemControlHighlightAccentBrush}" />
  77. <TextBlock Text="▲ Current (top)" FontSize="11" Opacity="0.45" Margin="0,-4,0,0" />
  78. <StackPanel x:Name="StackVisPanel" Spacing="4" />
  79. <TextBlock Text="▼ Root (bottom)" FontSize="11" Opacity="0.45" Margin="0,4,0,0" />
  80. </StackPanel>
  81. </ScrollViewer>
  82. </Border>
  83. </Grid>
  84. </UserControl>