#!/bin/bash
# Sorts through npb raw files and produces an TAB delimited
# output that can read into a spread sheet. 

if ! [ -d "$1" ]; then
echo "Usage: get-results results-directory"
exit 1
fi
FILES=`ls $1`
for F in $FILES
do
	NAME=`grep PROGRAM $1/$F | sed -e 's/PROGRAM//'|sed -e 's/==================//g'`
	TOPS1=`grep Mop $1/$F|grep total| sed -e 's/Mop\/s total     =                 / /g'`
	POPS1=`grep Mop $1/$F|grep process|sed -e 's/Mop\/s\/process   = //g'`
	count=1
	echo "Test=$F"
	echo -e "Program\tMOPS Per Proc\tTotal MOPS"
	for N in $NAME
	do
		echo -n -e $N "\t"
		echo -n -e `echo $POPS1|cut -d" " -f$count` "\t"
		echo $TOPS1|cut -d" " -f$count
		let "count+=1"
		done
	echo ""
done
exit 0
