Measure CPU Use

衡量CPU的使用Measure CPU Use

有效地使用CPU可以使应用程序更快更有效地运行。尽管您正在为特定平台编写应用程序,但请记住,即使是相同的通用平台也有不同的CPU能力。工具帮助您在各种条件下进行测试,从而使您能够确定应用程序使用多个核心、线程和其他资源有多好。Effective use of the CPU allows your app to run faster and more effectively. Although you are writing an app for a particular platform, keep in mind that even the same general platform has different CPU capabilities. Instruments helps you conduct testing under a variety of conditions, allowing you to identify how well your app uses multiple cores, threads, and other resources.

轨道芯线使用Track Core and Thread Use

时间分析器概要模板使用时间分析器工具来执行在系统CPU上运行的进程的低开销、基于时间的采样。随着时间的推移,更有效地使用多个核心和线程,应用程序的性能会更好。时间分析器工具中的CPU和线程策略显示了一个应用程序如何利用内核和线程。The Time Profiler profiling template uses the Time Profiler instrument to perform low-overhead, time-based sampling of processes running on the system’s CPUs. The more effectively multiple cores and threads are used over time, the better an app’s performance. The CPU and thread strategies in the Time Profiler instrument show how well an app utilizes cores and threads.

查看核心或线程使用情况To view core or thread usage

  1. 运载工具。Launch Instruments.
  2. 在出现的分析模板选择对话框中,单击“时间分析器”。In the profiling template selection dialog that appears, click Time Profiler.
  3. 从目标设备和流程列表中选择您的设备和应用程序。Choose your device and app from the target device and process lists.
  4. 单击“选择”创建跟踪文档。Click Choose to create a trace document.
  5. 单击“记录”按钮在工具栏(或按command-r)开始记录。Click the Record button () in the toolbar (or press Command-R) to begin recording.
  6. 正常使用你的应用程序或系统。Use your app or the system normally.
  7. 请单击“停止”按钮,或按command-r再次,当完成。Click the Stop button (), or press Command-R again, when complete.
  8. 单击跟踪文档工具栏中的CPU或线程策略按钮。Click the CPU or threads strategy button in the trace document toolbar.
  9. 检查收集的数据。Examine the collected data.

使用CPU策略使用视图比较给定时间段的核心使用情况。有效的核心并发性提高了应用程序的性能。寻找不平衡的核心使用。如果单个内核有大量使用的区域,而其他内核保持安静,则可以指示需要更大优化的区域。当放大时,活动可能出现在多个线程上,但是更仔细的检查可能会显示出其他情况。因此,在检查核心用法时,一定要在跟踪窗格中进行缩放。Use the CPU strategy usage view to compare core usage over given time periods. Effective core concurrency improves an app’s performance. Look for unbalanced core usage. If a single core has areas of heavy usage while other cores remain quiet, that can indicate areas that need greater optimization. When zoomed out, activity may appear to be occurring on multiple threads, but a closer inspection may reveal otherwise. Therefore, be sure to zoom in on the track pane when examining core usage.

使用线程策略视图检查应用程序在执行工作时的线程使用情况。主线程上的大量工作会使应用程序的用户界面反应迟钝或缓慢。只要有可能,工作应该从主线上移开。Use the threads strategy view to examine your app’s use of threads when performing work. Large amounts of work on the main thread can make your app’s user interface unresponsive or slow. Whenever possible, work should be moved off the main thread.

寻找性能瓶颈Look for Performance Bottlenecks

性能监视器计数器(PMCS)是硬件寄存器,处理器中的事件发生的措施。它们通过识别特定类型的过度事件来帮助发现应用程序中的瓶颈。例如,大量的条件分支指令可能表示一段逻辑,如果重新排列,可能会降低所需分支的数量。PMC事件使这些问题得以解决,但这取决于您如何将它们与您的代码相匹配,并决定它们将如何帮助您改进应用程序的性能。计数器剖析模板使用计数器工具跟踪PMC事件。Performance monitor counters (PMCs) are hardware registers that measure events occurring in the processor. They help find bottlenecks in your app by identifying an excessive number of events of a particular type. For example, a high number of conditional branch instructions may indicate a section of logic that, if rearranged, might lower the number of branches required. PMC events bring these issues to light, but it is up to you to match them to your code and decide how they will help you improve your app’s performance. The Counters profiling template uses the Counters instrument to track PMC events.

跟踪PMC事件To track PMC events

  1. 运载工具。Launch Instruments.
  2. 在出现的剖析模板选择对话框中,单击计数器。In the profiling template selection dialog that appears, click Counters.
  3. 从目标设备和流程列表中选择您的设备和应用程序。Choose your device and app from the target device and process lists.
  4. 单击“选择”创建跟踪文档。Click Choose to create a trace document.
  5. 单击时间轴窗格中的计数器工具。Click the Counters instrument in the timeline pane.
  6. 记者command-2显示督察窗格记录设置。Press Command-2 to show record settings in the inspector pane.
  7. 在“检查面板”的“记录设置”区域中,单击事件表和公式表中的Add按钮(+)。In the record settings area of the inspector pane, click the Add button (+) in the Events and Formulas table.
  8. 选择您想要计数的事件。Select the event you’d like to count.
  9. 如果需要,重复步骤7和步骤8以添加更多事件。Repeat steps 7 and 8 to add more events, if desired.
  10. 单击“记录”按钮在工具栏(或按command-r)开始记录。lick the Record button () in the toolbar (or press Command-R) to begin recording.
  11. 正常使用你的应用程序或系统。Use your app or the system normally.
  12. 请单击“停止”按钮,或按command-r再次,当完成。Click the Stop button (), or press Command-R again, when complete.
  13. 检查收集的数据。Examine the collected data.

IMPORTANT

可以跟踪的PMC事件数量取决于硬件。尝试您的设置,以确定您可以跟踪多少事件,而不会造成错误。The number of PMC events that can be tracked is hardware dependent. Experiment with your setup to determine how many events you can track at once without causing an error.

TIP

如果您计划频繁记录相同的PMC事件,请将它们保存在分析模板中。否则,当您关闭文档时,它们就会丢失。有关保存分析模板的信息,请参阅将跟踪文档保存为分析模板。If you plan to record the same PMC events frequently, save them in a profiling template. Otherwise, they are lost when you close the document. For information on saving a profiling template, see Save a Trace Document as a Profiling Template.

测量CPU使用的其他方法Other Ways to Measure CPU Use

仪器提供了许多其他的分析模板,可以用来检查应用程序对CPU的使用情况。Instruments provides a number of other profiling templates that can be used to examine your app’s use of the CPU.

  • 与其他应用程序相比,使用活动监视器概要模板来衡量整个CPU的使用情况。Use the Activity Monitor profiling template to gauge overall CPU use in comparison to other apps.
  • 使用分派分析模板来查看您的调度队列何时执行。您可以看到分派线程持续多长时间和使用了多少块。Use the Dispatch profiling template to see when your dispatch queues are executed. You can see how long the dispatched thread lasts and how many blocks are used.
  • 使用系统跟踪剖析模板查看线程何时调度、活动时间、使用的核心以及更多。Use the System Trace profiling template to see when threads are scheduled, time active, core used, and more.
时间: 2024-09-29 22:21:26

Measure CPU Use的相关文章

C++ Measures CPU and memory consumption

We all know monitor, just as Windows Task Manager,can measure cpu used and memory cost. Now I record that today I studied.Firstly,shell goes first.-------Command 1-------#shell begin here#!/bin/ksh## Returns total memory used by process $1 in kb.## S

android内核剖析学习笔记:AMS(ActivityManagerService)内部原理和工作机制

一.ActivityManagerService提供的主要功能: (1)统一调度各应用程序的Activity (2)内存管理 (3)进程管理 二.启动一个Activity的方式有以下几种: (1)在应用程序中调用startActivity启动指定的Activity (2)在Home程序中单击一个应用图标,启动新的Activity (3)按"Back"键,结束当前Activity,返回到上一个Activity (4)长按"Home"键,显示出当前正在运行的程序列表,从

Rainmeter 一部分 语法 中文教程

;Meter基本元素示例:;如果是[MeterStyle]表示Meter的公共Style,类似CSS的意义!!!;颜色可以使用网页的颜色定义方式,如半透明黄色:255.255.0.128=FFFF0080[MeterTEST]X=0Y=0W=100H=20;设为1为隐藏,0(默认值)Hidden=0;如只需要绘制静态图形或静态文字的话可以不写MeasureName=MeasureStyleFontColor=#FontColor#FontFace=#FontFace#FontSize=#Font

android应用加速优化与分析,兼谈launcher优化。

android应用开发使用java语言,java是开发门槛比较低,运行效率比较低,开发人员的素质相差比较大.导致java程序开发容易,优化和维护比较困难.个人认为java的核心在于自动化内存管理和跨平台,但其诟病也在这一块,至于效率,随着硬件的发展,越来越不再是人们考虑的重点.很多人会写java程序,却不怎么会优化java程序,遇到内存泄露,遇到空对象,遇到超时,遇到概率性的内存BUG,常常无从下手.因为能解决这些问题的工具实在太多了,这也说明java的优化是个世界性问题,问题的表象可能一个,但

J-Link Commander

本文以J-Link ARM V4.35为例进行说明. 1 命令     输入?可以查询所支持的命令: J-Link>? Available commands are: ---------------------- f Firmware info h halt g go Sleep Waits the given time (in milliseconds). Syntax: Sleep <delay> s Single step the target chip st Show hardw

erlang 调度器CPU利用率低排查

-问题起因 近期线上一组服务中,个别节点服务器CPU使用率很低,只有其他1/4.排除业务不均,曾怀疑是系统top统计错误,从Erlang调度器的利用率调查 找到通过erlang:statistics(scheduler_wall_time) 查看服务器CPU低的机器调度器实际的CPU利用率很高接近100%,而其他机器都不到30%. 分析不同业务服务,发现只有在node 中进程数采用调度器CPU利用低这个问题. -Whatsapp 案例 erlang方面能找到案例不多,幸运的发现whatsapp

Measure Java Performance – Sampling or Instrumentation

copy from https://blog.codecentric.de/en/2011/10/measure-java-performance-sampling-or-instrumentation/ In recent discussions, I noticed a confusion about the differences between measuring with Sampling andInstrumentation.I hear about which one should

Powershell脚本实时获取所有cpu使用时间非0的进程

Powershell脚本实时获取所有cpu使用时间非0的进程,并将名称一致的进程合并. #定义结果输出路径 $OutFile = "D:\CPU_" + (Get-Date).GetDateTimeFormats()[1] + ".csv" #定义性能收集器对象 $CpuCores = (Get-WMIObject Win32_ComputerSystem).NumberOfLogicalProcessors $Processes = Get-Counter &qu

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 res