Browse Source

Hochladen Latenztest

fstange 3 years ago
parent
commit
28f2e179d3
2 changed files with 54 additions and 0 deletions
  1. 2 0
      rt-tests/Links.txt
  2. 52 0
      rt-tests/mklatencyplot.bash

+ 2 - 0
rt-tests/Links.txt

@@ -0,0 +1,2 @@
+https://www.embedded-software-engineering.de/echtzeit-mit-dem-raspberry-pi-und-linux-preemptrt-a-630498/
+https://www.osadl.org/Create-a-latency-plot-from-cyclictest-hi.bash-script-for-latency-plot.0.html

+ 52 - 0
rt-tests/mklatencyplot.bash

@@ -0,0 +1,52 @@
+#!/bin/bash
+
+# 1. Run cyclictest
+/home/pi/rt-tests/cyclictest -l10000000 -m -Sp90 -i200 -h400 -q >output
+
+# 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
+cores=4
+
+# 5. Create two-column data sets with latency classes and frequency values for each core, for example
+for i in `seq 1 $cores`
+do
+  column=`expr $i + 1`
+  cut -f1,$column histogram >histogram$i
+done
+
+# 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`
+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
+
+# 8. Execute plot command
+gnuplot -persist <plotcmd
+