* Allow specification of both base-period and servo period
* Allow use of standard suffixes (e.g., ms, us, ns) when specifying period to te st * Allow testing of one-thread systems (specify "-" or 0 for other period)
This commit is contained in:
parent
2aaf618a62
commit
5829d4cb38
1 changed files with 76 additions and 10 deletions
|
|
@ -3,16 +3,81 @@ T=`mktemp -d`
|
|||
trap 'cd /; [ -d $T ] && rm -rf $T' SIGINT SIGTERM EXIT
|
||||
cd $T
|
||||
|
||||
PERIOD=${1-25000}
|
||||
if [ $PERIOD -lt 1000 ]; then
|
||||
UPERIOD=$PERIOD
|
||||
PERIOD=$((UPERIOD*1000))
|
||||
else
|
||||
UPERIOD=$((PERIOD/1000))
|
||||
fi
|
||||
calc() { echo "scale=1; $1" | bc; }
|
||||
icalc() { echo "scale=0; ($1)*1" | bc | sed 's/\..*//'; }
|
||||
|
||||
parse_time () {
|
||||
case $1 in
|
||||
-) echo "0" ;;
|
||||
*ns) icalc "${1%ns}" ;;
|
||||
*us|*µs) icalc "1000*${1%us}" ;;
|
||||
*ms) icalc "1000*1000*${1%ms}" ;;
|
||||
*s) icalc "1000*1000*1000*${1%s}" ;;
|
||||
*) if [ $1 -lt 1000 ]; then icalc "1000$*1"; else icalc "$1"; fi ;;
|
||||
esac
|
||||
}
|
||||
|
||||
human_time () {
|
||||
if [ "$1" -eq 0 ]; then echo "-"
|
||||
elif [ "$1" -ge 1000000000 ]; then echo "$(calc $1/1000/1000/1000)s"
|
||||
elif [ "$1" -ge 1000000 ]; then echo "$(calc $1/1000/1000)ms"
|
||||
elif [ "$1" -ge 1000 ]; then echo "$(calc $1/1000)µs"
|
||||
else echo "$1ns"
|
||||
fi
|
||||
}
|
||||
|
||||
BASE=$(parse_time 25us); SERVO=$(parse_time 1ms)
|
||||
case $# in
|
||||
0) ;;
|
||||
1) BASE=$(parse_time $1) ;;
|
||||
2) BASE=$(parse_time $1); SERVO=$(parse_time $2) ;;
|
||||
*)
|
||||
echo "Usage: latency-test [base-period [servo-period]]"
|
||||
echo "Default: latency-test 25us 1ms"
|
||||
echo "Times may be specified with suffix \"s\", \"ms\", \"us\" \"µs\", or \"ns\""
|
||||
echo "Times without a suffix and less than 1000 are taken to be in us;"
|
||||
echo "other times without a suffix are taken to be in ns"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
if [ "$BASE" -gt "$SERVO" ]; then TEMP=$BASE; BASE=$SERVO; SERVO=$TEMP; fi
|
||||
if [ "$BASE" -eq "$SERVO" ]; then BASE=0; fi
|
||||
|
||||
BASE_HUMAN=$(human_time $BASE)
|
||||
SERVO_HUMAN=$(human_time $SERVO)
|
||||
if [ $BASE -eq 0 ]; then
|
||||
cat > lat.hal <<EOF
|
||||
loadrt threads name1=fast period1=$PERIOD name2=slow period2=1000000
|
||||
loadrt threads name1=slow period1=$SERVO
|
||||
loadrt timedelta count=1
|
||||
addf timedelta.0 slow
|
||||
start
|
||||
loadusr -Wn lat pyvcp lat.xml
|
||||
net sl timedelta.0.max => lat.sl
|
||||
net sj timedelta.0.jitter => lat.sj
|
||||
net st timedelta.0.out => lat.st
|
||||
waitusr lat
|
||||
EOF
|
||||
|
||||
cat > lat.xml <<EOF
|
||||
<pyvcp>
|
||||
<title title="EMC2 / HAL Latency Test"/>
|
||||
<axisoptions/>
|
||||
<table>
|
||||
<tablerow/><tablespan columns="5"/><label wraplength="5i" justify="left">
|
||||
<text>
|
||||
"""Let this test run for a few minutes, then note the maximum Jitter. You will use it while configuring emc2.
|
||||
|
||||
While the test is running, you should "abuse" the computer. Move windows around on the screen. Surf the web. Copy some large files around on the disk. Play some music. Run an OpenGL program such as glxgears. The idea is to put the PC through its paces while the latency test checks to see what the worst case numbers are."""
|
||||
</text>
|
||||
</label>
|
||||
<tablerow/><label/><label text="Max Interval (ns)" font="Helvetica 12 italic"/><label text="Max Jitter (ns)" font="Helvetica 12 italic"/><label text="Last interval (ns)" font="Helvetica 12 italic"/>
|
||||
<tablerow/><label text="Servo thread ($SERVO_HUMAN):"/><s32 halpin="sl"/><s32 halpin="sj" font="Helvetica 12 bold"/><s32 halpin="st"/>
|
||||
</table>
|
||||
</pyvcp>
|
||||
EOF
|
||||
else
|
||||
cat > lat.hal <<EOF
|
||||
loadrt threads name1=fast period1=$BASE name2=slow period2=$SERVO
|
||||
loadrt timedelta count=2
|
||||
addf timedelta.0 fast
|
||||
addf timedelta.1 slow
|
||||
|
|
@ -40,10 +105,11 @@ While the test is running, you should "abuse" the computer. Move windows around
|
|||
</text>
|
||||
</label>
|
||||
<tablerow/><label/><label text="Max Interval (ns)" font="Helvetica 12 italic"/><label text="Max Jitter (ns)" font="Helvetica 12 italic"/><label text="Last interval (ns)" font="Helvetica 12 italic"/>
|
||||
<tablerow/><label text="Servo thread (1ms):"/><s32 halpin="sl"/><s32 halpin="sj" font="Helvetica 12 bold"/><s32 halpin="st"/>
|
||||
<tablerow/><label text="Base thread (${UPERIOD}µs):"/><s32 halpin="bl"/><s32 halpin="bj" font="Helvetica 12 bold"/><s32 halpin="bt"/>
|
||||
<tablerow/><label text="Servo thread ($SERVO_HUMAN):"/><s32 halpin="sl"/><s32 halpin="sj" font="Helvetica 12 bold"/><s32 halpin="st"/>
|
||||
<tablerow/><label text="Base thread ($BASE_HUMAN):"/><s32 halpin="bl"/><s32 halpin="bj" font="Helvetica 12 bold"/><s32 halpin="bt"/>
|
||||
</table>
|
||||
</pyvcp>
|
||||
EOF
|
||||
fi
|
||||
|
||||
halrun lat.hal
|
||||
|
|
|
|||
Loading…
Reference in a new issue