# Analysis tools

Source: [https://docs.qualcomm.com/doc/80-70014-10/topic/13-performance_tools.html](https://docs.qualcomm.com/doc/80-70014-10/topic/13-performance_tools.html)

Analysis tools are used to examine CPU performance.

### Function tracer (ftrace)

- Ftrace is a tool designed to offer insights into the kernel’s
                        operations.
- It is used for debugging or analyzing latencies and performance issues.
- It also serves as a tracing tool to collect kernel space traces for
                        analysis.

To collect ftrace, follow these steps:

1. To enable trace events, run the following commands from the SSH shell:

        mount -t debugfs none /sys/kernel/debugCopy to clipboard

        echo 0 > /sys/kernel/tracing/tracing_onCopy to clipboard

        echo 25600 > /sys/kernel/tracing/buffer_size_kbCopy to clipboard

        echo "" > /sys/kernel/tracing/set_eventCopy to clipboard

        echo "" > /sys/kernel/tracing/traceCopy to clipboard
2. To check the available events, run the following command:

        cat /sys/kernel/tracing/available_eventsCopy to clipboard
3. To enable the required events, for example, a scheduler trace, run the following
                    commands:

        echo 1 > /sys/kernel/tracing/events/sched/sched_wakeup_new/enableCopy to clipboard

        echo 1 > /sys/kernel/tracing/events/sched/sched_waking/enableCopy to clipboard

        echo 1 > /sys/kernel/tracing/events/sched/sched_switch/enableCopy to clipboard
4. To check the set events, run the following command:

        cat /sys/kernel/debug/tracing/set_eventCopy to clipboard
5. To start a trace, run the following command:

        echo 1 > /sys/kernel/tracing/tracing_onCopy to clipboard
6. Run use cases.
7. To stop trace after the use case, run the following command:

        echo 0 > /sys/kernel/tracing/tracing_onCopy to clipboard
8. To save the trace, run the following command:

        cat /sys/kernel/tracing/trace > /opt/ftrace.txtCopy to clipboard
9. To pull ftrace from the target to the host, use SCP or a similar tool. Here is
                    an example command:

        scp -r root@10.92.162.185:/opt/ftrace.txt /local/mnt/workspace/logsCopy to clipboard

Note: Ensure to specify the
                        target IP address in this command.

For more information on ftrace, see [https://www.kernel.org/doc/html/v4.17/trace/ftrace.html](https://www.kernel.org/doc/html/v4.17/trace/ftrace.html).

### Linux Trace Toolkit next generation (LTTng)

- LTTng is an open-source tracing tool.
- It is used to trace the Linux kernel and user space simultaneously.

For more information on LTTng, see [https://lttng.org/docs/v2.13/](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 machine. For more information, see [https://projects.eclipse.org/projects/tools.tracecompass](https://projects.eclipse.org/projects/tools.tracecompass).

### Qualcomm Profiler

- Qualcomm® Profiler CLI is a command-line interface tool.
- It is used as a performance profiling tool to identify, measure, and
                        optimize application scaling improvement opportunities across Qualcomm
                        system-on-chip (SoC).
- It supports CPU, process, memory, and I/O profiling metrics.

Note: The device must be connected to
                the Windows host machine to run Qualcomm Profiler.

Download the Qualcomm Profiler tool from the [Qualcomm Software Center (QSC)](https://softwarecenter.qualcomm.com/#/) on to the host machine. It is installed
                at C:\Program
                    Files(x86)\Qualcomm\Shared\QualcommProfiler\API\target-le.

After the Qualcomm Profiler tool is installed using the QSC, set it up using the
                following documents available at the specified paths:
- C:\Program Files
                            (x86)\Qualcomm\Shared\QualcommProfiler\API\documents\Readme.txt
- C:\Program Files
                            (x86)\Qualcomm\Shared\QualcommProfiler\API\documents\80-54323-2\_AE\_Qualcomm\_Profiler\_CLI\_UG.pdf

For more information, see [Qualcomm Profiler CLI for Linux](https://docs.qualcomm.com/bundle/publicresource/topics/80-54323-3/getting-started.html).

### Perf utility

- The Perf utility is an open-source profiling tool in Linux to read
                        performance monitoring unit (PMU) counters.
- It is used to obtain the function call stack.

It is part of the Qualcomm Linux build. To run the perf utility, run the following
                commands:

    setenforce 0Copy to clipboard

    perfCopy to clipboard

For more information, see [https://perf.wiki.kernel.org/index.php/Main_Page](https://perf.wiki.kernel.org/index.php/Main_Page).

### systemd-analyze

- Systemd-analyze is a command-line tool used to analyze and debug system
                        bootup performance in Linux.
- It measures boot time milestones and analyzes bottlenecks at different
                        layers such as the kernel, user space platform, and services.

The Yocto system recipe comes with the systemd-analyze tool by default.

To compile and install the `systemd-analyze`utility, follow these
                    steps:
- On the host:
    1. Compile `systemd-analyze.ipk` by running the
                                    following command in your
                                    workspace:

            bitbake systemdCopy to clipboard
    2. This generates the .ipk file in the following directory:

        /build-qcom-wayland/tmp-glibc/deploy/ipk/armv8-2a/systemd-analyze\_250.5-r0\_armv8-2a.ipk
- On the target:

    1. Push the .ipk file into the device from the host using SCP or a
                                    similar tool. Here is an example command:

scp systemd-analyze_250.5-r0_armv8-2a.ipk root@10.92.162.185:/var/cache/Copy to clipboard

Note: Ensure
                                        to specify the target IP address in this command.
    2. Install the .ipk file by running the following
                                    command:

            opkg install /var/cache/systemd-analyze_250.5-r0_armv8-2a.ipkCopy to clipboard

For more information, see [https://www.freedesktop.org/software/systemd/man/latest/systemd-analyze.html](https://www.freedesktop.org/software/systemd/man/latest/systemd-analyze.html).

Last Published: Jul 12, 2024

[Previous Topic
Features](https://docs.qualcomm.com/bundle/publicresource/80-70014-10/topics/2-performance-features.md) [Next Topic
Configure](https://docs.qualcomm.com/bundle/publicresource/80-70014-10/topics/14-configure.md)