> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyze performance with tools

Examine the system performance with the following analysis tools:

* [Function tracer (ftrace)](#function-tracer-ftrace): Debugs and analyzes latencies and performance issues
  > **Note**
  >
  > To enable ftrace, verify kernel config `CONFIG_FTRACE` is set to `y` in `arch/arm64/configs/qcom.config`. If it isn't set, ftrace doesn't work.
* [LTTng](#linux-trace-toolkit-next-generation-lttng): Traces Linux kernel and userspace simultaneously
* [Trace Compass (Eclipse)](#trace-compass-by-eclipse): Visualizes performance issues graphically
* [Qualcomm Profiler CLI](#qualcomm-profiler-cli): Profiles and optimizes application scaling on Qualcomm SoCs
* [Perf Utility](#perf-utility): Evaluates performance monitoring unit (PMU) counters in Linux
* [Systemd-analyze](#systemd-analyze): Analyzes and debugs system boot performance in Linux

## **Function tracer (ftrace)**

This tool provides insights into the kernel's operations. [Function Tracer](https://www.kernel.org/doc/html/v4.17/trace/ftrace.html) is useful for debugging or analyzing latencies and performance issues. Function tracer serves as a tracing tool to collect kernelspace traces for analysis.

To collect ftrace, do the following:

<Note>
  The commands specified in the following steps should be run on the device.
</Note>

1. To enable trace events, run the following commands on the device from the SSH shell:
   ```text theme={null}
   mount -t debugfs none /sys/kernel/debug
   ```
   ```text theme={null}
   echo 0 > /sys/kernel/tracing/tracing_on
   ```
   ```text theme={null}
   echo 25600 > /sys/kernel/tracing/buffer_size_kb
   ```
   ```text theme={null}
   echo "" > /sys/kernel/tracing/set_event
   ```
   ```text theme={null}
   echo "" > /sys/kernel/tracing/trace
   ```
2. To check the available events, run the following command:
   ```text theme={null}
   cat /sys/kernel/tracing/available_events
   ```
3. To enable the required events, for example, a scheduler trace, run the following commands:
   ```text theme={null}
   echo 1 > /sys/kernel/tracing/events/sched/sched_wakeup_new/enable
   ```
   ```text theme={null}
   echo 1 > /sys/kernel/tracing/events/sched/sched_waking/enable
   ```
   ```text theme={null}
   echo 1 > /sys/kernel/tracing/events/sched/sched_switch/enable
   ```
4. To understand the set events, run the following command:
   ```text theme={null}
   cat /sys/kernel/debug/tracing/set_event
   ```
5. To start a trace, run the following command:
   ```text theme={null}
   echo 1 > /sys/kernel/tracing/tracing_on
   ```
6. Run use cases.
7. To stop the trace after running use cases, run the following command:
   ```text theme={null}
   echo 0 > /sys/kernel/tracing/tracing_on
   ```
8. To save the trace, run the following command:
   ```text theme={null}
   cat /sys/kernel/tracing/trace > /opt/ftrace.txt
   ```
9. To pull ftrace from the target device to the host computer, use a secure copy protocol (SCP) or a similar tool. Ensure that you specify the target IP address in the command. The following is an example command to run on the host computer:
   ```text theme={null}
   scp -r root@10.92.162.185:/opt/ftrace.txt /local/mnt/workspace/logs
   ```

## **Linux Trace Toolkit next generation (LTTng)**

LTTng is an open-source tracing tool. It's used to trace the Linux kernel and userspace simultaneously.

For more information, see [LTTng Documentation](https://lttng.org/docs/v2.13/).

## **Trace Compass by Eclipse**

Trace Compass is an open-source tool that provides a graphical view for analyzing performance issues.

It can parse several types of traces including ftrace and LTTng, and visualize the following:

* Kernel resources
* Kernel control flow
* User space marker

Trace Compass is a host application that requires a Java virtual machine to work on the host computer.

For more information, see [Eclipse Trace Compass](https://projects.eclipse.org/projects/tools.tracecompass).

To download Trace Compass, see [Eclipse Trace Compass - Downloads](https://projects.eclipse.org/projects/tools.tracecompass/downloads).

## **Qualcomm<sup>®</sup> Profiler CLI**

Qualcomm Profiler is a performance profiling tool to identify, measure, and optimize application scaling improvement opportunities across Qualcomm system-on-chips (SoCs). It supports CPU, GPU, aDSP, cDSP, userspace processes, memory, and I/O profiling metrics.

For detailed information about how to use the Qualcomm Profiler tool, see [Qualcomm Profiler User Guide](https://docs.qualcomm.com/bundle/publicresource/topics/80-54323-2/introduction.html).

To download the Qualcomm Profiler tool on the host computer, do the following:

1. Download and install the Qualcomm Software Center.
2. Launch Qualcomm Software Center, search for Qualcomm Profiler, and download it.

## **Perf utility**

The Perf utility is an open-source profiling tool in Linux to monitor the PMU counters. It's used to obtain a function call stack. It's part of the Qualcomm<sup>®</sup> Linux<sup>®</sup> build.

For more information, see [perf: Linux profiling with performance counters](https://perfwiki.github.io/main/).

To run the perf utility, run the following command on the device:

```text theme={null}
perf --help
```

## **systemd-analyze**

Systemd-analyze is a command-line tool to analyze and debug system boot performance in Linux. It measures boot time milestones and analyzes bottlenecks at different layers, such as the kernel, userspace platform, and services. The Yocto system recipe comes with the systemd-analyze tool by default.

For more information, see [systemd-analyze — Analyze and debug system manager](https://www.freedesktop.org/software/systemd/man/latest/systemd-analyze.html).

The `systemd-analyze` binary is included in the Qualcomm<sup>®</sup> Linux<sup>®</sup> build by default.

## **Next steps**

* [Configure CPU, GPU, and memory](./configure-cpu-gpu-and-memory)
