---
title: "【性能分析】Snapdragon Profiler"
author: "Perrin Yong"
author_profile: https://www.pystone.net/profile/
published_by: "Perrin Yong"
canonical: https://www.pystone.net/notes/snapdragon-profiler-usage/
type: note
content_role: unspecified
visibility: public
id_stability: rename-stable
source_path: "10-计算机、信息技术与工程/05-游戏图形与运行时/游戏性能优化/【性能分析】Snapdragon Profiler.md"
content_hash: dbd1ff83f110fe252067dc7e483f6ad7bf26b9474a11b8a211c617ac38f597b3
knowledge_version: 224c990773de.5fa8af6e39fa
site_commit: 224c990773de166d23a886306577dd90379529ce
notes_commit: 5fa8af6e39fa3891d1b9b4832bfa6c4e0ecaaf0a
---
# 【性能分析】Snapdragon Profiler

﻿# 【性能分析】Snapdragon Profiler

> 创建时间：2021/8/9 17:59

* 基本概念
    * CPU, GPU, DSP
      * CPU
      * GPU
      * DSP
    * Clock Speed
    * Branch predictor
  * SnapSragonProfiler参数
  * Identify Application Bottlenecks
    * Frame rate
  * Ref

## 基本概念

### CPU, GPU, DSP

#### CPU

CPU is a general purpose processor. General Purpose in the sense that it is designed to perform a number of operations but the way these operations are performed may not be best for all applications. Graphics or Video Processing is one such example. Although a CPU can perform these tasks (which involve repeated additions/multiplications which may be performed in parallel) , the performance achieved is not good enough for modern applications.

#### GPU

Graphics processing Unit or GPU is designed to accelerate creation of images for a computer display. A CPU consists of a few cores optimized for sequential serial processing while a GPU consists of thousands of smaller, more efficient cores designed for handling multiple tasks simultaneously. They are designed to perform functions such as texture mapping, image rotation, translation, shading, etc. They may also support operations such as motion compensation, calculation of inverse DCT, etc. for accelerated video decoding.

#### DSP

Digital Signal Processor or DSP is optimized for high speed processing of numeric data representing the analog signals in real time. They are designed for quickly performing large number of numeric operations repeatedly on a series of data samples and are ideal for processing streaming digital signals. They provide functionalities that are helpful for DSP applications such as bit reverse addressing which is helpful for FFT computation, architectural support for very tight extremely low overhead loops, saturation arithmetic, etc.

### Clock Speed

**clock speed** (also “ **clock rate** ” or “ **frequency** ”) - measures the number of cycles your CPU executes per second, measured in GHz (gigahertz).

A “ **cycle** " is technically a pulse synchronized by an internal oscillator, but for our purposes, they’re a basic unit that helps understand a CPU’s speed.

Sometimes, multiple instructions are completed in a single clock cycle;
in other cases, one instruction might be handled over multiple clock cycles.

  * Some game engines benefit more from strong single-thread performance than multithreading.
  * Many newer AAA games, especially in multithreading-friendly engines like Unreal Engine 4, can benefit both from extra cores and increased clock.

时钟周期（Clock Cycle）- 在一个时钟周期内，CPU仅完成一个最基本的动作。

CPU周期亦称机器周期 - 完成一个基本操作所需要的时间称为机器周期。通常用内存中读取一个指令字的最短时间来规定CPU周期。

### Branch predictor

branch predictor - a digital circuit that tries to guess which way a branch (e.g., an if–then–else structure) will go before this is known definitively.

![assets/0011 - 【性能分析】Snapdragon Profiler__resource-001-65dc68f2aec3.png](/media/f6740d55131da4ccaf03.png)

Without branch prediction, the processor would have to wait until the conditional jump instruction has passed the execute stage before the next instruction can enter the fetch stage in the pipeline.

The branch predictor attempts to avoid this waste of time by trying to guess whether the conditional jump is most likely to be taken or not taken. The branch that is guessed to be the most likely is then fetched and speculatively executed. If it is later detected that the guess was wrong, then the speculatively executed or partially executed instructions are discarded and the pipeline starts over with the correct branch, incurring a delay.

The time that is wasted in case of a **branch misprediction** is equal to the number of stages in the pipeline from the fetch stage to the execute stage. Modern microprocessors tend to have quite long pipelines so that the misprediction delay is between 10 and 20 clock cycles. As a result, making a pipeline longer increases the need for a more advanced branch predictor.

Implementations:
Static branch prediction
Dynamic branch prediction
Random branch prediction
Next line prediction
...

很好的例子：https://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-processing-an-unsorted-array

## SnapSragonProfiler参数

## Identify Application Bottlenecks

看帧率 -> 确认是GPU-bound还是CPU-bound app -> 如果都不是，看是否是 Vsync-bound app.

### Frame rate

Frame rate is an ideal place to start. Apps such as games usually run best at 30 or 60 frames per second (fps) and sometimes higher for virtual and extended reality (VR/XR) apps.

average frame rate
consistency of the frame rate

## Ref

https://www.intel.com/content/www/us/en/gaming/resources/cpu-clock-speed.html
https://zhuanlan.zhihu.com/p/90829922
https://en.wikipedia.org/wiki/Branch_predictor

https://developer.qualcomm.com/software/snapdragon-profiler/app-notes/identify-application-bottlenecks
