mklatencyplot.bash 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/bin/bash
  2. # 1. Run cyclictest
  3. /home/pi/rt-tests/cyclictest -l10000000 -m -Sp90 -i200 -h400 -q >output
  4. # 2. Get maximum latency
  5. max=`grep "Max Latencies" output | tr " " "\n" | sort -n | tail -1 | sed s/^0*//`
  6. # 3. Grep data lines, remove empty lines and create a common field separator
  7. grep -v -e "^#" -e "^$" output | tr " " "\t" >histogram
  8. # 4. Set the number of cores, for example
  9. cores=4
  10. # 5. Create two-column data sets with latency classes and frequency values for each core, for example
  11. for i in `seq 1 $cores`
  12. do
  13. column=`expr $i + 1`
  14. cut -f1,$column histogram >histogram$i
  15. done
  16. # 6. Create plot command header
  17. echo -n -e "set title \"Latency plot\"\n\
  18. set terminal png\n\
  19. set xlabel \"Latency (us), max $max us\"\n\
  20. set logscale y\n\
  21. set xrange [0:400]\n\
  22. set yrange [0.8:*]\n\
  23. set ylabel \"Number of latency samples\"\n\
  24. set output \"plot.png\"\n\
  25. plot " >plotcmd
  26. # 7. Append plot command data references
  27. for i in `seq 1 $cores`
  28. do
  29. if test $i != 1
  30. then
  31. echo -n ", " >>plotcmd
  32. fi
  33. cpuno=`expr $i - 1`
  34. if test $cpuno -lt 10
  35. then
  36. title=" CPU$cpuno"
  37. else
  38. title="CPU$cpuno"
  39. fi
  40. echo -n "\"histogram$i\" using 1:2 title \"$title\" with histeps" >>plotcmd
  41. done
  42. # 8. Execute plot command
  43. gnuplot -persist <plotcmd