CPU Performance tuning for iOS performance optimization

Source: Internet
Author: User

Analyze CPU usage in your application

Source: http://www.cnblogs.com/chensheng12330/p/3947585.html

It is important to ensure that all available resources are used effectively to write code for your application. The most important of these is your CPU resources. Efficient use of CPUs allows applications to run faster and more efficiently. Even if you will be writing application-specific platforms, remember that even the same type can have a common platform with different CPU capabilities. The CPU trace template gives you the means to determine how your application uses multiple cores and how much energy and other resources you use to measure.

looking for bottlenecks and Performance monitor counters

Performance Monitor counter (PMC) hardware registers, which measure events that occur on the processor. They can be used to help identify bottlenecks in your application by identifying excessive amounts of a specific type of event. For example, a large number of conditional branching instructions may indicate a logic that, if rescheduled, may reduce the number of branches required. Although the PMC event can bring these problems, it is up to you to match your code and decide that they will help you improve the performance of your application.

In the tool, you use counter instruments to track the PMC events.

Track PMC Event counter Instruments
    1. Open the Counter tracking template.

    2. Click the Inspector button counter for the instrument.

    3. Click the plus button (+).

    4. Click the event to change to another event.

The PMC Event List populates a set of initial common events. You can add events that are specific to your application through the Window menu.

Add a new PMC event
    1. Select Window > Management point events.

    2. Click the state that corresponds to the desired event and select either visible or favorite.

It is important to note that the number of PMC events that can be traced is dependent on the hardware. Trying to track too many events can cause an error. Test settings to determine the number of events that can be successfully tracked once.

If you plan to record the same PMC events frequently, save them in a template. Otherwise, they will lose when you close the document. To save the trace information template, see Save an instrument tracking template .

Track individual Events

The Event Analyzer Tool tracks Performance Monitor interrupt (PMI) events, but in this case there is only one event trace and you can get more details. Sets the size of each collected sample set for the Event Analyzer tool. Event Analyzer then provides you with information on how to actively track PMI events in the sample. Use the track these sample display panes to identify a large number of activities. After determining the high active area, use the details pane to get more information in each particular example.

Add a new PMI event
    1. Select Window > Management point events.

    2. Click state corresponds to event and select visible or most Like.

Select the PMI event you want to track by selecting it from the event name pop-up menu control. If the required events are not listed, make sure that you have enabled it. See Adding a new PMC event to create a new event. The figure shows that the event Analyzer tracks a PMC event.

Figure Track a PMI event with the Event Analyzer Tool

Energy Saving and energy diagnostic tracking templates

The Energy Diagnostic Tracking template provides diagnostics on energy use, as well as basic on/off status major equipment components. The template consists of energy use, CPU activity, network activity, display brightness, sleep/wake, Bluetooth, wireless network, and GPS instruments.

Energy diagnostic logging, your iOS device records devices that are not used in conjunction with energy-related data. Because log records are valid, you can record all the day. The log lasts while the iOS device is in sleep mode, but if the device battery is dry or the iOS device is powered off, the running log data is lost.

The development of developer Setup seems to be only available on the device. Sets the device to disappear after a reboot. Xcode restore settings by connecting the device or instrument.

After enough energy usage events are logged, you can analyze them from phone to Xcode by importing log data from the Energy diagnostic template. Look for areas of high energy use and see if you can reduce the use of energy in these areas.

Track energy use on iOS devices
    1. Open the Developer login iOS device where you want to capture the data.

    2. Use the user's perspective to debug your app.

    3. After getting the data, turn off the development log.

Reduce the energy used by your application by making sure you turn off Recode. You can verify if you have to turn off a specific radio using the Energy diagnostic tracking template. Each broadcast is specified with a red description trace and a black panel, specifying that it is off.

use template with multi-core trace check thread

Multi-core trace templates analyze multicore performance, including thread status, scheduling queues, and blocking usage. It is the dispatch threading tool.

The thread state tool gives you a graphical representation of each thread state that runs at a specific time. Each block uses a different color to help you identify each thread. After multiple thread state changes it is easy to change the color of the recognition tracking pane. Figure 7 shows that four threads are being traced.

Figure 7 Thread status tracking template for thread activity display

to view the thread usage of an application
    1. Select the multi-core trace template.

    2. Run your application.

    3. Select a thread by selecting the check box to check the tag column in the details pane.

The actions pane is captured in the following trace. The color symbol is the default color for each action, but they can change you.

  • Unknown/terminating (gray). the instrument could not determine the state of the thread or be terminated.

  • Wait (yellow). The thread is waiting for another thread to perform a specific action.

  • pause (dark blue). The thread is put into a pending state and will not persist until it is specifically told to resume running.

  • requires a pause (light blue). A thread that has sent a request will go into a pending state.

  • run (green). The thread is running.

  • Run Queue (black). The threads in the queue run. After that, it will run a CPU.

  • wait for uninterrupted (uninterrupted) (orange). The thread is waiting for another thread to perform a specific action and the wait period cannot be interrupted.

  • idling Processor (white). A processor thread is active, but no action is taken.

With thread-state instrumentation, multi-core templates contain dispatch instruments. Use the scheduling tool to view when you execute the dispatch queue. You can see how long and how many blocks the dispatch thread will last.

the multi-core trace template shows interaction in the application thread. However, you are not able to see which cores are being used. See Core usage applications , see in- Depth Research core usage Time Analyzer trace template .

In- depth study of core usage Time Analyzer trace template

The profiler trace template performs a low-overhead process that runs on the CPU of a time-based sampling system. It contains the Time Analyzer tool.

The Time Analyzer tool for CPU policy shows how the application takes advantage of multicore. Select the CPU in the strategy tracking document in the Configuration Trace pane to display the time on the x-axis and the y-axis of the processor core. CPU policies use views to help compare core usage over a given time period. Effective core concurrency increases the performance of the application. Re-use a single core while other areas of the core remain quiet can describe areas that require greater optimization.

View the use of a single core
    1. Open the Time Analyzer tool.

    2. Select your app to select a target from the pop-up menu.

    3. Tap record, exercise your app, and then click Stop to capture data.

    4. Click the CPU Policy button.

    5. Select Use.

    6. Looking for core use imbalance.

Make sure your application is using multiple cores while zooming through the trace pane. Quickly the core of a jump between one or two threads can make it like when using multiple cores simultaneously in reality, only one core is used at any time.

CPU Performance tuning for iOS performance optimization

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.