Analyzing CPU Performance in Embedded Systems with Linux

Analyzing CPU Performance in Embedded Systems with Linux

Command
cat /proc/cpuinfo

processor       : 0
BogoMIPS        : 48.00
Features        : fp asimd evtstrm crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x2
CPU part        : 0xd05
CPU revision    : 0

processor       : 1
BogoMIPS        : 48.00
Features        : fp asimd evtstrm crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop asimddp
CPU implementer : 0x41
CPU architecture: 8
CPU variant     : 0x2
CPU part        : 0xd05
CPU revision    : 0
  • <span>processor</span>: Indicates the CPU core number, starting from 0
  • <span>BogoMIPS</span>: Abbreviation for “Bogus Million Instructions Per Second”, not a real performance metric.
    • This is a rough estimate used by Linux at startup to gauge CPU latency (mainly for timing).
    • A higher value indicates that the CPU can execute empty instruction loops faster, but it cannot be used to compare performance.
  • <span>Features</span>: The hardware features (instruction set extensions) supported by this CPU
    • fp: Floating-point operations
    • asimd: ARM SIMD (similar to NEON, vector instructions)
    • crc32: CRC32 instruction
    • atomics: Support for atomic operations
    • fphp, asimdhp: Half-precision floating-point support
    • cpuid: CPUID instruction support (can query features)
    • asimddp, lrcpc, dcpop etc.: ARMv8.2 or higher instruction extensions
  • <span>CPU implementer</span>: Vendor identifier
    • 0x41 indicates ARM Holdings (i.e., official ARM cores, not customized cores from Qualcomm, Apple, etc.)
  • <span>CPU architecture</span>: Indicates the ARM architecture version
    • 8 is ARMv8 (64-bit architecture, supports AArch64 mode)
  • <span>CPU variant</span>: Indicates different variants of the same CPU model (e.g., different process versions)
  • <span>CPU part</span>: Specific CPU model
    • 0xd05 is Cortex-A55, a high-performance, low-power ARMv8.2-A architecture core, commonly found in embedded or mobile chips.
  • <span>CPU revision</span>: Indicates the revision version of this core

CPU Usage

Command
top

top - 00:25:34 up 25 min,  1 user,  load average: 0.00, 0.00, 0.02
Tasks: 108 total,   1 running, 107 sleeping,   0 stopped,   0 zombie
%Cpu(s):  0.3 us,  0.3 sy,  0.0 ni, 99.2 id,  0.0 wa,  0.2 hi,  0.0 si,  0.0 st
MiB Mem :    855.4 total,    267.6 free,    344.3 used,    243.5 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    435.2 avail Mem

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
384 root      20   0  365092  72716  36888 S   0.7   8.3   0:11.84 mxapp2
407 root      20   0 1432752  80108  35220 S   0.7   9.1   0:07.74 dockerd

System Load

top - 00:25:34 up 25 min,  1 user,  load average: 0.00, 0.00, 0.02
  • 00:25:34: Current time
  • up 25 min: The system has been running for 25 minutes
  • 1 user: Current number of logged-in users
  • load average: 0.00, 0.00, 0.02
    • <span>1 minute</span>, <span>5 minutes</span>, <span>15 minutes</span> average load (number of processes in the run queue per core)
    • A value close to 0 indicates that the system is idle. This machine is very idle.

Task Status

Tasks: 108 total,   1 running, 107 sleeping,   0 stopped,   0 zombie
  • 108 total: A total of 108 processes
  • 1 running: Currently, 1 process is running (using CPU)
  • 107 sleeping: The rest are waiting (most system or daemon processes are in this state)
  • 0 zombie: No zombie processes (processes that have ended but have not yet been collected)

CPU Usage

%Cpu(s):  0.3 us,  0.3 sy,  0.0 ni, 99.2 id,  0.0 wa,  0.2 hi,  0.0 si,  0.0 st
  • <span>us</span>: User space usage 0.3% (running normal programs)
  • <span>sy</span>: Kernel space usage 0.3% (running system calls)
  • <span>ni</span>: Processes with nice values occupy 0.0%
  • <span>id</span>: CPU idle time 99.2%
  • <span>wa</span>: Waiting for I/O (disk/network) time 0.0%
  • <span>hi</span>: Hardware interrupt time 0.2%
  • <span>si</span>: Software interrupt time 0.0%
  • <span>st</span>: Steal Time time stolen by the virtual machine 0.0%

Overall, the CPU is almost idle, and the system is under very little pressure.

RAM Memory Usage

MiB Mem :    855.4 total,    267.6 free,    344.3 used,    243.5 buff/cache
MiB Swap:      0.0 total,      0.0 free,      0.0 used.    435.2 avail Mem
Physical Memory
  • <span>total</span>: Total system memory 855.4 MiB.
  • <span>free</span>: Free memory 267.6 MiB.
  • <span>used</span>: Memory used by programs.
  • <span>buff/cache</span>: Memory used by the system for cache or buffers, which can be reclaimed.
Swap Space
  • <span>total</span>: Swap is not enabled
  • <span>avail Mem</span>: Approximately 435.2 MiB available (free + reclaimable)

Process List

PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND
384 root      20   0  365092  72716  36888 S   0.7   8.3   0:11.84 mxapp2
407 root      20   0 1432752  80108  35220 S   0.7   9.1   0:07.74 dockerd
...
Field Meaning
PID Process ID
USER Owner user (root)
PR Priority
NI Nice value (compensation for scheduling priority)
VIRT Total virtual memory (including mmap, shared libraries, etc.)
RES Actual physical memory usage (resident memory)
SHR Shared memory
S Status (S=Sleeping)
%CPU CPU usage rate
%MEM Memory usage rate
TIME+ Total running time
COMMAND Process name
Example Explanation
  • mxapp2 (PID 384): uses 8.3% memory, 0.7% CPU, running time 11.84 seconds.
  • dockerd (PID 407): is the Docker daemon, using 9.1% memory, CPU usage is also very low.

CPU Temperature

Command
cat /sys/class/thermal/thermal_zone0/temp
48500
  • This path is the thermal sensor interface of the Linux kernel, used to read the current temperature of the CPU or SoC (may vary slightly depending on the platform).
    • <span>thermal_zone0</span>: Indicates the first thermal sensor (usually the CPU).
    • <span>temp</span>: Indicates the current temperature, in milli-degrees Celsius (1/1000 degrees Celsius).

CPU Stress Testing

yes Command

<span>yes</span> is a very simple but useful command-line tool for stress testing, which continuously outputs a string (default is y) until forcibly stopped. Because yes continuously performs output operations (string + newline), it will continuously occupy the CPU, making it very suitable for simple CPU usage testing.

Test Command
yes &gt; /dev/null &amp;
  • Each yes instance fully occupies 1 CPU core; run as many instances as there are cores.
  • Using & indicates running in the background.
  • To terminate the test:<span>killall yes</span>
View Metrics
Metric Category Parameter Name Method of Acquisition Description
🔧 CPU Usage Per-core usage rate <span>top</span>, <span>htop</span> The goal is for each core usage rate to approach 100%
🔁 Load Average 1/5/15 minute load <span>cat /proc/loadavg</span> <span>loadavg</span> ≈ number of CPU cores indicates the load is just right
🌡 Temperature CPU temperature <span>cat /sys/class/thermal/thermal_zone*/temp</span> Check if it exceeds the temperature limit (e.g., 85℃)
🕓 Response Latency System response speed Estimate command response time using <span>time ls</span>, <span>ping localhost</span>
📈 Context Switches <span>ctxt</span> <span>cat /proc/stat</span> before and after comparison Check if context switches spike under high load
⏱ Interrupts <span>intr</span> <span>cat /proc/stat</span> Frequent interrupts may indicate system overload or hardware issues
💾 Free Memory <span>free -m</span>, <span>cat /proc/meminfo</span> Ensure memory is not being abnormally occupied
🚫 Errors/Warnings <span>dmesg</span> Check for warnings about CPU temperature, frequency limits, etc.

High-Precision π Calculation

time echo "scale=5000; 4*a(1)" | bc -l -q
  • time: Tests the execution time of the command
  • scale=5000: Calculates π to 5000 decimal places.
  • a(1) is the arctangent function, resulting in π/4.
  • 4*a(1) approximates π.

Analyzing CPU Performance in Embedded Systems with Linux

Previous Recommendations

RECOMMEND

Analyzing CPU Performance in Embedded Systems with Linux

[1]. Can FreeRTOS be low power? Really, just change these few configurations!

[2]. 【FreeRTOS Development】 Thoroughly Understand Event Flag Groups: A Tool for Multi-Task Synchronization

[3]. 【FreeRTOS Development】 Queue Development Code Explanation

[4]. 【FreeRTOS Development】 In-Depth Understanding of Memory Management Schemes

I am Aike, an embedded software engineer.

Follow me for more embedded insights.

Remember to like, share, and click “view”

Your encouragement is my greatest motivation to continue sharing!

See you next time.

Looking forward to your

sharing

likes

views

NEWS

WeChat IDaike_eureka

Baijiahao|Master Embedded Systems

Leave a Comment