Preempt-RT时延测试


在安装成功Preempt-RT之后,需要对系统进行了详细的时延测试,以判定该系统是否满足实时性需求。在安装Preempt-RT一文中已经简要介绍了时延的测试方法,本文将进行更为详细的时延测试工作。需要说明的是,短时间的运行cyclictest得出的结果是无意义的,再就是测试系统上没有合适负载的情况下运行cyslictest所得到的延时统计也是无意义的。本文分别在CPU空载和满负载的情况下对Preempt-RT的时延进行测试。

1. 模拟负载

  • 安装stress压力测试工具:
sudo apt-get install stress
  • 查看自己电脑的核心数:
cd /sys/devices/system/cpu
ls

我的结果显示cpu标号从cpu0~cpu7,因此核心数为8个

  • 让CPU满载运行:
strss --cpu 8
  • 查看结果:
sudo apt-get install htop
htop

2. 运行测试程序

  • 安装绘图工具gnuplot:
sudo apt-get install gnuplot
  • 空载测试
  1. 不使用stress工具
  2. 运行测试指令:
sudo cyclictest -m -Sp90 -i1000 -h400 -D 30m -q >ouput     #为了方便,我只运行了30分钟,实际测试应为1-2天,且不间断运行
  1. 运行脚本:
#!/bin/bash
echo "ready for plot \n"
# get maximum latency
max=`grep "Max Latencies" output | tr " " "\n" | sort -n | tail -1 | sed s/^0*//`
echo "max Latency is $max" 
# Grep data lines, remove empty lines and create a common field separator
grep -v -e "^#" -e "^$" output | tr " " "\t" >histogram 
# set the number of cores, for example
cores=8
# Create two-column data sets with latency classes and frequency values for each core
for i in `seq 1 $cores`
do
  column=`expr $i + 1`
  cut -f1,$column histogram >histogram$i
done
# Create plot command header
echo -n "set title \"Latency plot(No load)\"\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 \"Noloadplot.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
# enjoy
firefox plot.png
  • 满载测试
  1. 使用stress工具
stress --cpu 8  #我的cpu核心数为8个
  1. 运行测试指令:
sudo cyclictest -m -Sp90 -i1000 -h400 -D 30m -q >ouput
  1. 运行脚本:
#!/bin/bash
echo "ready for plot \n"
# get maximum latency
max=`grep "Max Latencies" output | tr " " "\n" | sort -n | tail -1 | sed s/^0*//`
echo "max Latency is $max" 
# Grep data lines, remove empty lines and create a common field separator
grep -v -e "^#" -e "^$" output | tr " " "\t" >histogram 
# set the number of cores, for example
cores=8
# Create two-column data sets with latency classes and frequency values for each core
for i in `seq 1 $cores`
do
  column=`expr $i + 1`
  cut -f1,$column histogram >histogram$i
done
# Create plot command header
echo -n "set title \"Latency plot(Full load)\"\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 \"Fullloadplot.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
# enjoy
firefox plot.png

上述程序参考自:Create a latency plot from cyclictest histogram data

3. 观察结果

空载时延测试结果:
在这里插入图片描述
满载时延测试结果:
在这里插入图片描述

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值