mirror of
https://github.com/toradex/rt-validation.git
synced 2025-04-27 11:00:47 +00:00
rt-tests: generate latency plot
- Generate a latency plot PNG file in /tmp/latency-plot.png. - Generate a latency summary file in /tmp/latency-summary.log. Related-to: TOR-1198 Signed-off-by: Ming Liu <ming.liu@toradex.com>
This commit is contained in:
parent
4e869b1d67
commit
d3b17bcee1
@ -4,7 +4,9 @@ ARG IMAGE_TAG=2-bullseye
|
||||
FROM --platform=$IMAGE_ARCH torizon/debian:$IMAGE_TAG
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install -y --no-install-recommends rt-tests \
|
||||
&& apt-get install -y --no-install-recommends gnuplot rt-tests \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
CMD ["cyclictest","-S","-p99","-i1000","-m","-D20m", "-q", "|", "tee", "cyclictest.log"]
|
||||
COPY rt-tests.sh /rt-tests.sh
|
||||
|
||||
CMD ["/rt-tests.sh"]
|
||||
|
63
rt-tests/rt-tests.sh
Executable file
63
rt-tests/rt-tests.sh
Executable file
@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Run cyclictest
|
||||
if ! cyclictest -S -p99 -i1000 -m -D12h -h400 -q >output; then
|
||||
echo "ERROR: cyclictest failed" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get maximum latency
|
||||
max=`grep "Max Latencies" output | tr " " "\n" | sort -n | tail -1 | sed s/^0*//`
|
||||
|
||||
# Grep data lines, remove empty lines and create a common field separator
|
||||
grep -v -e "^#" -e "^$" output | tr " " "\t" >histogram
|
||||
|
||||
# Create two-column data sets with latency classes and frequency values for each core
|
||||
cores=$(grep -c ^processor /proc/cpuinfo)
|
||||
for i in `seq 1 $cores`
|
||||
do
|
||||
column=`expr $i + 1`
|
||||
cut -f1,$column histogram >histogram$i
|
||||
done
|
||||
|
||||
# Create plot command header
|
||||
echo -n -e "set title \"Latency plot\"\n\
|
||||
set terminal png\n\
|
||||
set xlabel \"Latency (us), max $max us\"\n\
|
||||
set logscale y\n\
|
||||
set xrange [0:400]\n\
|
||||
set yrange [0.8:*]\n\
|
||||
set ylabel \"Number of latency samples\"\n\
|
||||
set output \"plot.png\"\n\
|
||||
plot " >plotcmd
|
||||
|
||||
# Append plot command data references
|
||||
for i in `seq 1 $cores`
|
||||
do
|
||||
if test $i != 1
|
||||
then
|
||||
echo -n ", " >>plotcmd
|
||||
fi
|
||||
cpuno=`expr $i - 1`
|
||||
if test $cpuno -lt 10
|
||||
then
|
||||
title=" CPU$cpuno"
|
||||
else
|
||||
title="CPU$cpuno"
|
||||
fi
|
||||
echo -n "\"histogram$i\" using 1:2 title \"$title\" with histeps" >>plotcmd
|
||||
done
|
||||
|
||||
# Execute plot command
|
||||
gnuplot -persist <plotcmd
|
||||
|
||||
# Print summary to /tmp
|
||||
echo "Generating latency summary to /tmp/latency-summary.log"
|
||||
grep -e "^#" output >/tmp/latency-summary.log
|
||||
|
||||
# Copy plot to /tmp/latency-plot.png
|
||||
echo "Generating latency plot to /tmp/latency-plot.png"
|
||||
cp plot.png /tmp/latency-plot.png
|
||||
|
||||
# Clean up
|
||||
rm -f histogram* output plotcmd plot.png
|
Loading…
Reference in New Issue
Block a user