head	1.1;
access;
symbols;
locks
	dfk:1.1; strict;
comment	@# @;


1.1
date	96.07.04.02.59.41;	author dfk;	state Exp;
branches;
next	;


desc
@@


1.1
log
@Initial revision
@
text
@#!/bin/csh -f
#
# newextract-one - get a list of stats from one test case
#   This is very different from the old extract-one.  It only pulls
# out some interesting dependent variables, and does it in a way that
# makes the file more easily usable by other tools, and more easily 
# extendible.  It also incorporates the function of average directly.
#
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              January 1995
#                          dfk@@cs.dartmouth.edu

if ($#argv < 1) then
	echo 'usage: newextract-one  pat.nio.ncomp  metric...'
	echo '  looks for files of the form pat.nio.ncomp.trial.sim*'
	echo '  produces  files of the form pat.nio.ncomp.data'
	echo "  'metric' is the short name for a metric" 
	exit 1
endif

set base=$1
shift
set metrics=($argv:q)

set awkfile=/tmp/newex$$.awk
set trialfile=/tmp/newex$$.trials
onintr cleanup

# build an awk script to extract the metrics
echo > $awkfile
foreach metric ($metrics)
  echo '/\['$metric'\]/ {print "'$metric'", $NF; next}' >> $awkfile
end

# Extract those metrics from each of the sim files corresponding
# to the given base name.  
set ntrials=0
echo > $trialfile
foreach sim ($base.*.sim*)
	statgraph -m -f $sim |& awk -f $awkfile >> $trialfile
	@@ ntrials = $ntrials + 1
end

# now collapse the multiple trials into a file with format
#   metricname n mean sd cv
set data=$base.metrics
echo > $data
foreach metric ($metrics)
  # pull out the lines containing this metric, and then only the values
  # then compute some stats about them: n mean sd cv
  grep ^$metric $trialfile | colex 2 | stats n mean sd | \
	dm \"$metric\" x1 x2 x3 'x3 != 0 ? x3/x2 : 0' >> $data
end

# they should all have the same column 2, the number of trials
# (I don't need sort before uniq, because if they're not all the same,
# they're not all the same, and that's all I need to know)
set trials=`colex 2 < $data | uniq`
if ("$trials" != $ntrials) then
  echo $base': differing numbers of trials ('$trials') than files('$ntrials')'
  rm -f $data
endif

cleanup:
# rm -f $awkfile $trialfile
@
