zoukankan      html  css  js  c++  java
  • Measure Graphics Performance

    测量的图形性能Measure Graphics Performance

     

     

    在iOS应用程序中广泛使用图形可以使你的应用脱颖而出。但是,除非你负责任地使用图形资源,否则你的应用程序会慢下来,降低电池寿命,看起来平庸,不管你想渲染的内容有多好。最佳图形性能:Extensive use of graphics in your iOS app can make your app stand out from your competitors. But unless you use graphics resources responsibly, your app will slow down, reduce battery life, and look mediocre no matter how good the content you are trying to render. For optimal graphic performance:

    • 确保动画的帧速率足以提供流畅的视觉体验,而不会对应用程序性能产生负面影响。Ensure that the frame rate of animations is sufficient for providing a fluid visual experience without negatively impacting app performance.

    • 减少应用程序使用的视图数量。Reduce the number of views your app uses.

    • 减少不透明性的使用,例如在显示半透明模糊的视图中。如果您需要使用不透明性,请避免在频繁更新的视图上使用它。否则,能源成本被放大,因为无论内容变化,背景视图和半透明视图都必须更新。Reduce the use of opacity, such as in views that exhibit a translucent blur. If you need to use opacity, avoid using it over views that are updated frequently. Otherwise, energy cost is magnified, as both the background view and the translucent view must be updated whenever content changes.

    • 绘制到屏幕的较小部分,只有变化的部分。要做到这一点,使用needstodrawrect:或getrectsbeingdrawn:计数:确定具体地区的更新,并把结果drawRect:。Draw to smaller portions of the screen—only the portions that are changing. To do this, use needsToDrawRect: or getRectsBeingDrawn:count: to identify the specific area to update, and pass the result to drawRect:.

    • 消除图当你的应用程序或其内容是不可见的;例如,当应用程序在后台,或当其含量是其他观点,遮挡裁剪,或画外。Eliminate drawing when your app or its content is not visible; for example, when your app is in the background, or when its content is obscured by other views, clipped, or offscreen.

    • 在窗口大小调整期间消除绘图。Eliminate drawing during window resizing.

    在iOS中测量核心动画图形性能Measure Core Animation Graphics Performance in iOS

    核心动画剖析模板使用核心动画和时间分析器工具来测量iOS应用程序的图形和CPU性能。此模板提供了一个快速轻量级的起点,用于测量应用程序每秒呈现的帧数。它允许您快速查看应用程序呈现的帧比预期的少。通过关联您在取样时所做的工作,您可以识别需要优化的代码区域。The Core Animation profiling template uses the Core Animation and Time Profiler instruments to measure your iOS app’s graphics and CPU performance. This template provides a quick and lightweight starting point for measuring the number of frames per second rendered by your app. It allows you to quickly see where your app renders fewer frames than expected. By correlating what you were doing at the time the sample was taken, you can identify areas of your code that need to be optimized.

    NOTE

    使用核心动画模板对物理设备上的应用程序进行概要分析。在iOS模拟器中分析应用程序并不能产生真实的真实结果。Use the Core Animation template to profile an app on a physical device. Profiling an app in iOS Simulator does not produce true real-world results.

    不要使用核心动画工具测量opengl的ES性能。Do not use the Core Animation instrument to measure OpenGL ES performance.

    帧速率测量To measure frame rate
    1. 把你的iOS设备连接到你的Mac。Connect your iOS device to your Mac.

    2. 运载工具。Launch Instruments.

    3. 在出现的分析模板选择对话框中,单击“核心动画”。In the profiling template selection dialog that appears, click Core Animation.

    4. 从目标设备和流程列表中选择iOS设备和应用程序。Choose your iOS device and app from the target device and process lists.

    5. 单击“选择”创建跟踪文档。Click Choose to create a trace document.

    6. 单击“记录”按钮在工具栏(或按command-r)开始记录。Click the Record button (image: ../Art/inline_record_button_2x.png) in the toolbar (or press Command-R) to begin recording.

    7. 正常使用你的应用程序。Use your app normally.

    8. 请单击“停止”按钮,或按command-r再次,当完成。Click the Stop button (image: ../Art/inline_stop_button_2x.png), or press Command-R again, when complete.

    9. 检查收集的数据。Examine the collected data.

      详细窗格显示每个记录样本的帧速率。The detail pane shows the frame rate for each recorded sample.

    与结果相互关联Correlate Interactions with Results

    在用核心动画工具捕获数据后,您可能会看到时间轴窗格中的尖峰,其中应用程序的帧速率明显变好。然而,在某些情况下,通过改变横向和正常方向之间的设备,可能会导致尖峰,如果你不知道,你可能会花时间试图找出导致性能增加的原因。与结果交互关联的一种方法是在执行某些事件时向时间轴插入标志。查看设置标志。After capturing data with the Core Animation instrument, you may see spikes in the timeline pane where the frame rate of the app becomes appreciably better. In some cases, however, spikes can be caused by changing the device between landscape and normal orientation—and if you don’t know this, you might spend time trying to find what caused the performance increase. One way to correlate interactions with results is to insert flags into the timeline when you performed certain events. See Set Flags.

    调试选项Debugging Options

    核心动画包含了一些有用的调试选项,在“显示面板”的显示设置区域中。您不需要运行跟踪来在iOS设备上使用这些选项。Core Animation contains a number of useful debugging options in the display settings area of the inspector pane. You do not need to be running a trace to use these options on your iOS device.

    • 混色层。显示混合视图层。在混合的顶部绘制的混合视图可以用红色高亮显示。当选择此选项时,减少应用程序中红色的数量,可以显著提高应用程序的性能。混合视图层常常导致表滚动缓慢。Color Blended Layers. Shows blended view layers. Multiple view layers that are drawn on top of each other with blending enabled are highlighted in red. Reducing the amount of red in your app when this option is selected can dramatically improve your app’s performance. Blended view layers often cause slow table scrolling.

    • 颜色绿色,红色。用绿色或红色标记视图。一种观点认为,能够使用缓存的光栅化标为绿色。Color Hits Green and Misses Red. Marks views in green or red. A view that is able to use a cached rasterization is marked in green.

    • 彩色复制图像。显示由核心动画以蓝色复制的图像。Color Copied Images. Shows images that are copied by Core Animation in blue.

    • 颜色立即。删除执行彩色刷新操作时的10毫秒延迟。Color Immediately. Removes the 10 ms delay when performing color-flush operations.

    • 颜色不一致图像。在源像素与目标像素不对齐的图像上放置一个洋红叠加。Color Misaligned Images. Places a magenta overlay over images where the source pixels are not aligned to the destination pixels.

    • 彩色屏幕呈现黄色。在内容呈现画外黄色覆盖。Color Offscreen-Rendered Yellow. Places a yellow overlay over content that is rendered offscreen.

    • 彩色快速路径蓝。在内容,从排序分离蓝色覆盖。Color OpenGL Fast Path Blue. Places a blue overlay over content that is detached from the compositor.

    • 闪存更新区域。当图形处理器更新这些区域时,你的iOS设备上的颜色区域是黄色的。Flash Updated Regions. Colors regions on your iOS device in yellow when those regions are updated by the graphics processor.

    OpenGL是衡量activity inMeasure OpenGL Activity in iOS

    OpenGL ES分析模板使用OpenGL ES分析器和GPU驱动工具来测量和分析iOS应用程序中的OpenGL ES活动,以检测正确性和性能问题。它还建议如何解决发现的问题。The OpenGL ES Analysis profiling template uses the OpenGL ES Analyzer and GPU Driver instruments to measure and analyze OpenGL ES activity in your iOS app in order to detect correctness and performance problems. It also recommends how to address found problems.

    测量opengl活动To measure OpenGL Activity 
    1. 把你的iOS设备连接到你的Mac。Connect your iOS device to your Mac.

    2. 运载工具。Launch Instruments.

    3. 在出现的分析模板选择对话框中,单击opengl ES分析。In the profiling template selection dialog that appears, click OpenGL ES Analysis.

    4. 从目标设备和流程列表中选择iOS设备和应用程序。Choose your iOS device and app from the target device and process lists.

    5. 单击“选择”创建跟踪文档。Click Choose to create a trace document.

    6. 单击“记录”按钮在工具栏(或按command-r)开始记录。Click the Record button (image: ../Art/inline_record_button_2x.png) in the toolbar (or press Command-R) to begin recording.

    7. 使用你的应用程序,锻炼你的OpenGL ES图形代码。Use your app normally, exercising your OpenGL ES graphics code.

    8. 几秒钟后,测试,请单击“停止”按钮,或再次按下command-r。After a few seconds of measurement, click the Stop button (image: ../Art/inline_stop_button_2x.png), or press Command-R again.

    9. 检查收集的数据。Examine the collected data.

    错误在详细窗格中列出,按其严重程度排序。红色方块表示最严重的问题,橙色三角形表示较不严重的问题。在详细窗格中选定的问题中,在“检查窗格”的扩展详细区域中显示一个建议和堆栈跟踪。Errors are listed in the detail pane sorted by their severity. Red squares indicate the most severe problems, and orange triangles indicate less severe problems. A recommendation and the stack trace are displayed in the extended detail area of the inspector pane for the issue selected in the detail pane.

  • 相关阅读:
    优先队列
    Problem W UVA 662 二十三 Fast Food
    UVA 607 二十二 Scheduling Lectures
    UVA 590 二十一 Always on the run
    UVA 442 二十 Matrix Chain Multiplication
    UVA 437 十九 The Tower of Babylon
    UVA 10254 十八 The Priest Mathematician
    UVA 10453 十七 Make Palindrome
    UVA 10163 十六 Storage Keepers
    UVA 1252 十五 Twenty Questions
  • 原文地址:https://www.cnblogs.com/zyingn/p/Measure_Graphics_Performance.html
Copyright © 2011-2022 走看看