You are here: Home / Support / HOWTOs / 
2024-06-25 - 08:24

Dates and Events:

OSADL Articles:

2023-11-12 12:00

Open Source License Obligations Checklists even better now

Import the checklists to other tools, create context diffs and merged lists

2023-03-01 12:00

Embedded Linux distributions

Results of the online "wish list"

2022-01-13 12:00

Phase #3 of OSADL project on OPC UA PubSub over TSN successfully completed

Another important milestone on the way to interoperable Open Source real-time Ethernet has been reached

2021-02-09 12:00

Open Source OPC UA PubSub over TSN project phase #3 launched

Letter of Intent with call for participation is now available


HOWTO: Create a latency plot from cyclictest histogram data

Quick description with inlined code

1. Redirect the output of cyclictest to a file, for example

cyclictest -l100000000 -m -Sp90 -i200 -h400 -q >output 

(Please note that this will take 5 hours and 33 minutes.)

2. Get maximum latency

max=`grep "Max Latencies" output | tr " " "\n" | sort -n | tail -1 | sed s/^0*//`

3. Grep data lines, remove empty lines and create a common field separator

grep -v -e "^#" -e "^$" output | tr " " "\t" >histogram 

4. Set the number of cores, for example


(If the script is used on a variety of systems with a different number of cores, this can, of course, be determined from the system.)

5. Create two-column data sets with latency classes and frequency values for each core

for i in `seq 1 $cores`
column=`expr $i + 1`
cut -f1,$column histogram >histogram$i

6. 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

7. Append plot command data references

for i in `seq 1 $cores`
if test $i != 1
echo -n ", " >>plotcmd
cpuno=`expr $i - 1`
if test $cpuno -lt 10
title=" CPU$cpuno"
echo -n "\"histogram$i\" using 1:2 title \"$title\" with histeps" >>plotcmd

8. Execute plot command

gnuplot -persist <plotcmd

9. Enjoy

firefox plot.png

Download the script


Bash script (must be run as root)

1.2 K

Example plot

And this is how the resulting image may look like.

Example latency plot (click to enlarge)