代码改变世界

WP7 App性能优化(9):检测应用程序性能(Ⅱ)

2010-12-26 17:05  MagicKing110  阅读(1683)  评论(2编辑  收藏  举报

启用帧频计数器

Windows Phone 模拟器提供了帧频计数器以便于在开发时监测应用程序的性能。要启用帧频计数器,请设置P:System.Windows.Interop.Settings.EnableFrameRateCounter属性为true。该属性也可以通过当前应用程序设置来访问,如下代码所示。

Application.Current.Host.Settings.EnableFrameRateCounter = true;

注意:要看到帧频计数器,你可能需要将SystemTray.IsVisible属性设置为false.

以下示意图展示的便是帧频计数器。

Ff967560.ad000fc8-6d81-4290-9afa-5e03cfd078ca(en-us,VS.92).png

下面的表格描述了每一个计数器的作用。

计数器

描述

Composition Thread Frame Rate

该值指示屏幕的更新速率。也可以表示storyboard驱动的动画所支持的更新速率。该值应尽量接近60.当该值小于30时应用程序性能将会降低。当数值小于30时,计数器文本将显示为红色。

UI Thread Frame Rate

该值指示UI线程运行的速率。UI线程控制着输入、逐帧回调和其他非构图线程处理的绘制。这个值越大,应用程序的响应性越高。要保证一个可接受的用户输入相应时间,该值一般应在20以上。当该值小于30时其文本会显示为红色。

Texture Memory Usage

该值表示应用程序使用的纹理层拷贝需要的视频内存和系统内存。这不是应用程序的通用内存计数器,而仅仅是被表面显示层使用的内存。

Surface Counter

该值表示传递给GPU处理的原始表层数目。该数字的最大来源是自动、或由开发者缓存的元素。

Intermediate Surface Counter

该值表示生成为缓存表层结果的确切的表层数。这些表层由UI元素创建,因而应用程序可以在UI中精确地保持其Z轴顺序。

Fill Rate Counter

该值表示屏幕上每一帧绘制的像素数。数值1表示480*800像素。推荐值是2.5。当值大于3时其文本会显示为红色。

 

补充:

关于帧频计数器,Jeff Wilcox的博文《Frame rate counters in Windows Phone》也进行了很详细的介绍。以下片段摘自这这篇文章供参考。

NewerCounters

Target frame rates for good performance

When testing on a Windows Phone device, here are key performance metrics to try for. Understand that the emulator (XDE) performance may not be indicative of actual device performance.

Frame rate counters may be 0 when there is no animation being updated on the thread at any particular moment. You can add a very simple, continually animating and repeating, animation to your application during development & testing if you want to ensure that there is always some frame rate value available.

Counter Ideal Minimum Best Experience Theoretical Max
Render Thread 30 fps 60 fps 120 fps
UI Thread 15 fps > 15 fps 120 fps
Screen Fill Rate 1.0 <= 2.0 N/A

 

转到:WP7 App性能优化(0):索引页