#!/bin/csh -f
#
# extras - print summary extraneous reads and writes in a test case
#
set usage='usage: extras .simfile... '
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              Version 2.0
#                              January 1995
#                          dfk@cs.dartmouth.edu

if ($#argv == 0) then
    echo "$usage"
    exit 1
endif

foreach i ($*)
    echo $i
    if ($i =~ */wr*) then
	# it's a read pattern, expect 1280 reads and no writes
	set reads=1280
        set writes=0
    else
	# it's a write pattern, expect 1280 writes and no reads
	set reads=0
        set writes=1280
    endif

    statgraph -m'[diskread] Disk reads, per disk' -f $i \
        |& sed '1,/^Array Metric/d' \
        | awk 'NF==2 {print $2}' | stats sum | dm x1-$reads

    statgraph -m'[diskwrite] Disk writes, per disk' -f $i \
	|& sed '1,/^Array Metric/d' \
	| awk 'NF==2 {print $2}' | stats sum | dm x1-$writes

end
