#!/bin/csh -f
#
# get-OSDI-data -   gather the data for Excel spreadsheet
#   used in OSDI (and first TOCS) papers to compare thruputs 
#   does not include 2PIO data
#
#  must be run after 'update'
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              Version 3.0
#                              January 1996
#                          dfk@cs.dartmouth.edu

source environset

if ($#argv > 1) then
    echo usage: get-plain-data PlainConfigDir
    exit 1
endif

set configs=Configs-plain
if ($#argv == 1) set configs=$1

set tmp=/tmp/dfkget$$
onintr cleanup
mkdir $tmp

set patfile=$tmp/pats

foreach layout (contig rsectors)
    foreach iopfs (cache general)
        foreach sort (sort nosort)
	    if ($layout == contig && $sort == sort) continue
	    if ($iopfs == cache && $sort == sort) continue

	    foreach rec (8 8192)
		echo $layout $iopfs $sort $rec

		set datafile=$tmp/$layout.$iopfs.$sort.$rec
		echo > $datafile
		echo > $patfile

		foreach pat (wcn wcc wbc wcb wbb wnb wc wb)
		    dm x13/1024. >> $datafile \
			< $configs/$rec.1280.$iopfs.$sort.$layout.*/results/w$pat.16.16.avg
		    echo $pat >> $patfile
		end

		# wwn requires some special handling
		# use 8192 for both rec=8 and rec=8192
		dm x13/1024. >> $datafile\
		    < $configs/8192.1280.$iopfs.$sort.$layout.*/results/wwn.16.16.avg
		echo wn >> $patfile
		echo "" >> $datafile
		echo "" >> $patfile

		foreach pat (rcn rcc rbc rcb rbb rnb rc rb)
		    dm x13/1024. >> $datafile \
			< $configs/$rec.1280.$iopfs.$sort.$layout.*/results/w$pat.16.16.avg 
		    echo $pat >> $patfile
		end

		# wrn requires some special handling:
		# use 8192 for both rec=8 and rec=8192
		dm x13/1024. >> $datafile\
		    < $configs/8192.1280.$iopfs.$sort.$layout.*/results/wrn.16.16.avg
		echo rn >> $patfile
		echo "" >> $datafile
		echo "" >> $patfile

		# wrlw requires some special handling:
		# use 8192 for both rec=8 and rec=8192
		# use name 'ra' instead
		# divide by 16 to normalize
		dm x13/1024./16. >> $datafile\
		    < $configs/8192.1280.$iopfs.$sort.$layout.*/results/wrlw.16.16.avg
		echo ra >> $patfile
	    end
	end
    end
end

set data=OSDI-data
abut > $data.contig \
     $patfile \
     $tmp/contig.general.nosort.8 \
     $tmp/contig.cache.nosort.8 \
     $tmp/contig.general.nosort.8192 \
     $tmp/contig.cache.nosort.8192

abut > $data.rsectors \
     $patfile \
     $tmp/rsectors.general.nosort.8 \
     $tmp/rsectors.general.sort.8 \
     $tmp/rsectors.cache.nosort.8 \
     $tmp/rsectors.general.nosort.8192 \
     $tmp/rsectors.general.sort.8192 \
     $tmp/rsectors.cache.nosort.8192

echo output is in $data.{contig,rsectors}

cleanup:
rm -rf $tmp
