WPF 应用程序在 i5 处理器计算机上速度变慢
WPF 中开发的应用程序之一在 i5 处理器笔记本电脑上运行速度非常慢。 UI 在嵌套 Items 控件中包含多个用户控件(200 多个)。相同的应用程序在其中一台台式机上运行,性能良好。
下面是笔记本电脑的详细配置,其速度非常慢(渲染 UI 需要 50 秒):
操作系统:Windows XP Professional(5.1,Build 2600)Service Pack 3 (2600.xpsp_sp3_gdr.101209-1647 ) 系统制造商:联想 系统型号:2537W2K BIOS:版本 1.00PARTTBLx 处理器:Intel(R) Core(TM) i5 CPU M 520 @ 2.40GHz(4 个 CPU) 内存:3060MB RAM 页面文件:已用 784MB,可用 5172MB Windows 目录:C:\WINDOWS DirectX 版本:DirectX 9.0c (4.09.0000.0904) DX 设置参数:未找到 DxDiag 版本:5.03.2600.5512 32 位 Unicode
显示
卡名称:NVIDIA NVS 3100M 制造商: 英伟达 芯片类型:NVS 3100M DAC类型:集成RAMDAC 设备密钥:Enum\PCI\VEN_10DE&DEV_0A6C&SUBSYS_214217AA&REV_A2 显示内存:256.0 MB 当前模式:1680 x 1050(32 位)(60Hz) 显示器:ThinkPad 显示器 1440x900 显示器最大分辨率:1440,900
下面是桌面的详细配置,其速度快(6 秒渲染相同的 UI):
操作系统:Windows XP Professional(5.1,Build 2600)Service Pack 3( 2600.xpsp_sp3_gdr.101209-1647) 系统制造商:戴尔公司 系统型号:OptiPlex 755
BIOS:Phoenix ROM BIOS PLUS 版本 1.10 A04 处理器:Intel(R) Core(TM)2 Duo CPU E6550 @ 2.33GHz(2 个 CPU) 内存:2004MB RAM 页面文件:已用 1544MB,可用 2353MB Windows 目录:C:\WINDOWS DirectX 版本:DirectX 9.0c (4.09.0000.0904) DX 设置参数:未找到 DxDiag 版本:5.03.2600.5512 32 位 Unicode
显示卡
卡名称:Intel(R) Q35 Express 芯片组系列 制造商:英特尔公司 芯片类型:Intel(R) GMA 3100 DAC 类型:内部 设备密钥:Enum\PCI\VEN_8086&DEV_29B2&SUBSYS_02111028&REV_02 显示内存:384.0 MB 当前模式:1280 x 960(32 位)(60Hz) 显示器:即插即用显示器 显示器最大分辨率:1600,1200 驱动程序名称:igxprd32.dll 驱动程序版本:6.14.0010.4837(英文)
请帮助我了解渲染速度变慢的原因。
<Grid x:Name="grid" Margin="3,0,0,15" HorizontalAlignment="Center" VerticalAlignment="Top"
IsEnabled="{Binding IsEnableOrDisableControl}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70*" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="05" />
<RowDefinition Height="15" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<AppUserControl:NumericUPDown Value="{Binding Total, Mode=TwoWay}"
MinValue="2" MaxValue="{Binding MaxValue}" Grid.Column="0"
Grid.Row="0"
x:Name="NoOfFltr"
/>
<Button Background="Transparent" BorderBrush="Transparent" BorderThickness="0"
Grid.Column="2" Grid.Row="0" ToolTip="Plot" HorizontalAlignment="Left"
>
<Button.Content>
<Image Width="16" Height="16">
<Image.Source>
<BitmapImage UriSource="..\Pictures\icon.png" DecodePixelWidth="16" />
</Image.Source>
</Image>
</Button.Content>
<Button.InputBindings>
<MouseBinding Gesture="CTRL+LeftClick" Command="{Binding OpenNewWindowCommand}" CommandParameter="0" />
<MouseBinding Gesture="LeftClick" Command="{Binding OpenCommand}" CommandParameter="1" />
</Button.InputBindings>
</Button>
<TextBlock Text="Text1" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="0" />
<TextBlock Text="Text2" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="2" />
<TextBlock Text="Text3" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="4" />
<TextBlock Text="Text4" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="6" />
<Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="7" HorizontalAlignment="Left" Height="{Binding DataParameterHeight}">
<ItemsControl Name="BiquadItem" ItemsSource="{Binding Parameters }">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70*" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
</Grid.ColumnDefinitions>
<ComboBox Name="cmbType" Width="70" HorizontalAlignment="Left" VerticalAlignment="Top"
ItemsSource="{Binding Source={StaticResource mdwType}}" Grid.Column="0" SelectedValue="{Binding bqType, Mode=TwoWay}" >
</ComboBox>
<AppUserControl:UnitUpDown Value="{Binding frq, Mode=TwoWay}" MinValue="0"
MaxValue="24000" Grid.Column="2" IsEnabled="{Binding Status}" Increment="1"
/>
<AppUserControl:NumericUPDown Value="{Binding scale, Mode=TwoWay}"
Grid.Column="4" IsEnabled="{Binding Status}" DecimalPoint="2" Increment="0.01"
MinValue="{Binding ElementName=biquadGrid, Path=DataContext.MinVal}"
MaxValue="{Binding ElementName=bqgrid, Path=DataContext.MaxVal}" />
<AppUserControl:NumericUPDown Value="{Binding qFactors, Mode=TwoWay}"
MinValue="0.001" MaxValue="24" Grid.Column="6" IsEnabled="{Binding qStatus}" DecimalPoint="3" Increment="0.01"
/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Grid>
One of the developed application in WPF is running very slow on i5 process Laptop.
UI contains multiple user controls (200+) in nested Items control. Same application is running with good performance in one of the Desktop machine.
Below is the detailed configuration of Laptop where its very slow (50 sec to render the UI) :
Operating System: Windows XP Professional (5.1, Build 2600) Service Pack 3 (2600.xpsp_sp3_gdr.101209-1647)
System Manufacturer: LENOVO
System Model: 2537W2K
BIOS: Ver 1.00PARTTBLx
Processor: Intel(R) Core(TM) i5 CPU M 520 @ 2.40GHz (4 CPUs)
Memory: 3060MB RAM
Page File: 784MB used, 5172MB available
Windows Dir: C:\WINDOWS
DirectX Version: DirectX 9.0c (4.09.0000.0904)
DX Setup Parameters: Not found
DxDiag Version: 5.03.2600.5512 32bit Unicode
Display
Card name: NVIDIA NVS 3100M
Manufacturer: NVIDIA
Chip type: NVS 3100M
DAC type: Integrated RAMDAC
Device Key: Enum\PCI\VEN_10DE&DEV_0A6C&SUBSYS_214217AA&REV_A2
Display Memory: 256.0 MB
Current Mode: 1680 x 1050 (32 bit) (60Hz)
Monitor: ThinkPad Display 1440x900
Monitor Max Res: 1440,900
Below is the detailed configuration of Desktop where its fast (6 sec to render the same UI) :
Operating System: Windows XP Professional (5.1, Build 2600) Service Pack 3 (2600.xpsp_sp3_gdr.101209-1647)
System Manufacturer: Dell Inc.
System Model: OptiPlex 755
BIOS: Phoenix ROM BIOS PLUS Version 1.10 A04
Processor: Intel(R) Core(TM)2 Duo CPU E6550 @ 2.33GHz (2 CPUs)
Memory: 2004MB RAM
Page File: 1544MB used, 2353MB available
Windows Dir: C:\WINDOWS
DirectX Version: DirectX 9.0c (4.09.0000.0904)
DX Setup Parameters: Not found
DxDiag Version: 5.03.2600.5512 32bit Unicode
Display Card
Card name: Intel(R) Q35 Express Chipset Family
Manufacturer: Intel Corporation
Chip type: Intel(R) GMA 3100
DAC type: Internal
Device Key: Enum\PCI\VEN_8086&DEV_29B2&SUBSYS_02111028&REV_02
Display Memory: 384.0 MB
Current Mode: 1280 x 960 (32 bit) (60Hz)
Monitor: Plug and Play Monitor
Monitor Max Res: 1600,1200
Driver Name: igxprd32.dll
Driver Version: 6.14.0010.4837 (English)
Please help me to understand the cause to slow down the rendering.
<Grid x:Name="grid" Margin="3,0,0,15" HorizontalAlignment="Center" VerticalAlignment="Top"
IsEnabled="{Binding IsEnableOrDisableControl}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70*" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30" />
<RowDefinition Height="05" />
<RowDefinition Height="15" />
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<AppUserControl:NumericUPDown Value="{Binding Total, Mode=TwoWay}"
MinValue="2" MaxValue="{Binding MaxValue}" Grid.Column="0"
Grid.Row="0"
x:Name="NoOfFltr"
/>
<Button Background="Transparent" BorderBrush="Transparent" BorderThickness="0"
Grid.Column="2" Grid.Row="0" ToolTip="Plot" HorizontalAlignment="Left"
>
<Button.Content>
<Image Width="16" Height="16">
<Image.Source>
<BitmapImage UriSource="..\Pictures\icon.png" DecodePixelWidth="16" />
</Image.Source>
</Image>
</Button.Content>
<Button.InputBindings>
<MouseBinding Gesture="CTRL+LeftClick" Command="{Binding OpenNewWindowCommand}" CommandParameter="0" />
<MouseBinding Gesture="LeftClick" Command="{Binding OpenCommand}" CommandParameter="1" />
</Button.InputBindings>
</Button>
<TextBlock Text="Text1" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="0" />
<TextBlock Text="Text2" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="2" />
<TextBlock Text="Text3" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="4" />
<TextBlock Text="Text4" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Grid.Row="2" Grid.Column="6" />
<Grid Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="7" HorizontalAlignment="Left" Height="{Binding DataParameterHeight}">
<ItemsControl Name="BiquadItem" ItemsSource="{Binding Parameters }">
<ItemsControl.ItemTemplate>
<DataTemplate>
<Grid Margin="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70*" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
<ColumnDefinition Width="05" />
<ColumnDefinition Width="65" />
</Grid.ColumnDefinitions>
<ComboBox Name="cmbType" Width="70" HorizontalAlignment="Left" VerticalAlignment="Top"
ItemsSource="{Binding Source={StaticResource mdwType}}" Grid.Column="0" SelectedValue="{Binding bqType, Mode=TwoWay}" >
</ComboBox>
<AppUserControl:UnitUpDown Value="{Binding frq, Mode=TwoWay}" MinValue="0"
MaxValue="24000" Grid.Column="2" IsEnabled="{Binding Status}" Increment="1"
/>
<AppUserControl:NumericUPDown Value="{Binding scale, Mode=TwoWay}"
Grid.Column="4" IsEnabled="{Binding Status}" DecimalPoint="2" Increment="0.01"
MinValue="{Binding ElementName=biquadGrid, Path=DataContext.MinVal}"
MaxValue="{Binding ElementName=bqgrid, Path=DataContext.MaxVal}" />
<AppUserControl:NumericUPDown Value="{Binding qFactors, Mode=TwoWay}"
MinValue="0.001" MaxValue="24" Grid.Column="6" IsEnabled="{Binding qStatus}" DecimalPoint="3" Increment="0.01"
/>
</Grid>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
</Grid>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Microsoft 的 WPF Performance Suite(我的亮点):
在
ItemsControl
中渲染 200 多个复杂的UserControl's
是很多 - 至少对于用户交互来说是这样。笔记本电脑的图形能力可能是瓶颈。您可以考虑使用ListBox
来显示UserControl的
。ListBox
使用VirtualizingStackPanel
来启用 UI 虚拟化。此外,根据硬件上 Windows XP 上的 DirectX 支持,您可能会遇到性能问题。您甚至可以尝试在 Windows XP 计算机的显示属性中关闭硬件加速,看看是否可以提高 WPF 性能。
You can use the WPF Performance Suite from Microsoft (my highlight):
Rendering 200+ complex
UserControl's
within anItemsControl
is a lot - at least for the user to interact with. The graphical muscle of the laptop may be the bottleneck. You could consider using aListBox
to display theUserControl's
.ListBox
uses aVirtualizingStackPanel
to enable UI virtualization.Also, depending on the DirectX support on Windows XP on your hardware you may experience performance problems. You can even try to turn off hardware acceleration in the display properties of the Windows XP machine to see if that improves WPF performance.