#!/bin/sh
#
# frmspacing -- show spacing between frames, in ms
# 
# Usage: frmspacing runfile ...
#
# Can be used as a diagnostic tool to see if your frame triggering interval
# is fairly consistent.  If it's not, and it should be, you're likely getting
# false triggers or missed triggers.  Frame spacings that are out of line
# with the rest of the run will show you where the problem lies, and how
# pervasive it is.

if [ "$#" -eq 0 ]
then
	echo "Usage: frmspacing runfile ..." >&2
	exit 1
fi

for file
do
	echo "Frame spacings for $file:"
	dumprun -f "$file" |
	  sed -n 's/^Frame *\([0-9]*\):.*(\(.*\) ms)/\1 \2/p' |
	  awk '{if ($1 > 1)
			print "Frame " $1-1 " to " $1 ": " $2-last " ms";
		last=$2}'
	echo ""
done
