#!/bin/ksh

# use this to graph data files. we accept a directory full of data files
# to graph.

function do3dgraph {
	echo 3dgraph: $dir $1 $2 $3 $4
	./grapho -x "$3" -y "$4" -z 'time (usecs)' -o $dir/$1.ps $dir/$1.* \
		"$2"
}

function do2dgraph {
	echo 2dgraph: $dir $1 $2 $3
	./grapho -x "$3" -y 'time (usecs)' -o $dir/$1.ps $dir/$1.* \
		"$2"
}

function usage {
	echo "usage: $0 <datadir>"
}


if [ ! $# -gt 0 ]; then
	usage
	exit 0
fi

dir=$1

# add rules for tests here
if whence gnuplot; then
	do3dgraph	mutex	'-C # -t # -c [0-9]+ #' contention	nthreads
	do3dgraph	cond	'-S # -W # #'		signallers 	waiters
	do3dgraph	rwlock	'-W # -R # #'		readers 	writers
	do3dgraph	affinity '-t # -D # -B [0-9]+ #' threads 'domain size' 
	do3dgraph	sem	'-P # -W # #'		posters		waiters
	do2dgraph	syscall	'-t # #'		nthreads
	do2dgraph	life_cycle '-t # #'		nthreads
	exit 0
fi

echo "couldn't find gnuplot"
exit -1

