stress-tests: Improve stressing

*hackbench* doesn't produce much load on a SMP system. A better way to stress
the CPU is copying data from /dev/zero to /dev/null.

Running *du* and *find* doesn't stress Linux very much. Most of it is
optimised through caches. Better: run *dd* to copy the whole block device to
/dev/null.

To stress the network interface (but not your internet connection) send
massive pings to the gateway. In a docker container this might be the system
itself which wouldn't load the NIC. With the environment variable
STRESS_SERVER you can set a different address. The tool *ip* used to find
the gateway is in the package iproute2.
This commit is contained in:
Jörg Sommer 2023-06-28 18:47:39 +02:00
parent 1a880a38f6
commit 95cc35b4e8
2 changed files with 11 additions and 5 deletions

View File

@ -4,7 +4,7 @@ ARG IMAGE_TAG=2-bullseye
FROM --platform=$IMAGE_ARCH torizon/debian:$IMAGE_TAG FROM --platform=$IMAGE_ARCH torizon/debian:$IMAGE_TAG
RUN apt update \ RUN apt update \
&& apt install -y --no-install-recommends iperf3 rt-tests iputils-ping \ && apt install -y --no-install-recommends iperf3 rt-tests iputils-ping iproute2 \
&& apt clean \ && apt clean \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*

View File

@ -3,11 +3,14 @@
echo "Setting up stress tests..." echo "Setting up stress tests..."
# CPU load # CPU load
while true; do hackbench >/dev/null 2>&1; done & for i in $(seq $(nproc)); do dd if=/dev/zero of=/dev/null bs=4M & done
# I/O load (eMMC read) # I/O read load
while true; do du /usr >/dev/null 2>&1; done & for dev in /dev/mmcblk? /dev/sd?; do
while true; do find / -name a* >/dev/null 2>&1; done & test -b "$dev" || continue
while true; do dd if="$dev" of=/dev/null bs=4M; done &
done
# I/O load (USB read/write) # I/O load (USB read/write)
if mount | grep /mnt/pendrive >/dev/null; then if mount | grep /mnt/pendrive >/dev/null; then
@ -37,6 +40,9 @@ while true; do
done done
done & done &
ping -A -f -t 3 -q -s 49152 \
${STRESS_SERVER:-$(ip route get 1.1.1.1 |sed '/.* via \([^ ]*\) .*/ s//\1/; q')}
echo "RT stress tests started successfully!" echo "RT stress tests started successfully!"
# Dont exit # Dont exit