#!/bin/bash
#Usage: rawread 1.0.1 [options].
#-p N, N = number of processes (def=1).
#-d N, N = starting device e.g. 2 = raw2 or sdb (def=/dev/raw/raw1 or /dev/sda).
#-i N, N = if > 0, readv used and specifies number of iovecs (def=0).
#-s N, N = size of raw read buffer or each readv iovec length (def=256KB).
#-n N, N = num times to read or readv ..inner loop.. (def=1024).
#-l N, N = num times lseek to -o parm and repeat -n parm ..outer loop.. (def=1).
#-o N, N = lseek to offset N prior to starting inner loop (def=0).
#-x  ,     open /dev/sd.. instead of /dev/raw/raw.. (def=/dev/raw/raw..).
#-z  ,     add O_DIRECT flag to open, requires -x (def=O_RDONLY).
#-m N, N = device modulo, allow processes to use same device. (def= -p parm).
#-t N, N = test id (def = 0, sequential read() test)
#      0  = sequential read()
#      1  = sequential write()
#      2  = sequential readv()
#      3  = sequential writev()
#      4  = sequential pread()
#      5  = sequential pwrite()
#      6  = random read()
#      7  = random write()
#      8  = random readv()
#      9  = random writev()
#      10 = random pread()
#      11 = random pwrite()

. /etc/autobench.conf || . functions

# Install support files ######################################################
if [ ! \( -d $AUTODIR/sources/rawio -a -x $AUTODIR/sources/rawio/rawread \) ];
then
  log "Installing rawread benchmark"
  $AUTODIR/scripts/benchmarks/install/rawio || exit 2
fi

getcommand doprofilers
doprofilers install

export LD_LIBRARY_PATH=$AUTODIR/sources/rawio:$LD_LIBRARY_PATH
raw -qa > $LOGDIR/benchmark/rawbind.$RUN_NUMBER

startprofilers

$AUTODIR/sources/rawio/rawread $* | tee $LOGDIR/benchmark/rawioout.$RUN_NUMBER

stopprofilers
doprofilers report
doprofilers postprocess
