#!/bin/bash
# This is template script for running a benchmark
#
# List the arguments
# reqparam value
# optparam prefix "-f" 
#
. /etc/autobench.conf || . functions

# Process the arguments ######################################################
#if [ $# -lt 2 ]; then
#  echo "There are two required arguments"
#  exit 1
#fi
#ARG1=$1
#ARG2=$2


# Install support files ######################################################
# This often looks like:
#if [ ! -e $AUTODIR/sources/BENCHMARK_NAME ]; then
#  $AUTODIR/scripts/benchmarks/install/BENCHMARK_NAME || exit 2
#fi
# Also get any commands that this benchmark uses... especially profilers
getcommand doprofilers
doprofilers install

# Prepare the benchmark ######################################################

# i.e.
#touch $LOGDIR/benchmark/BENCHMARK_NAME.$RUN_NUMBER
#pushd $AUTODIR/sources/BENCHMARK_NAME > /dev/null

# Run the benchmark ##########################################################

startprofilers # start what ever profilers have been specified
#./BENCHMARK_NAME $ARG1 $ARG2 | tee $LOGDIR/benchmark/BENCHMARK_NAME.$RUN_NUMBER
stopprofilers # stop the profilers
doprofilers report # do the reporting
doprofilers postprocess  # and postprocessing

# If you want to do multiple iterations of the test.  It will often look like:
#
# for ((i=1;i<=$ARG1;i++)); do
#   startprofilers $i  
#   ./BENCHMARK_NAME $ARG2 | tee $LOGDIR/benchmark/BENCHMARK_NAME.$RUN_NUMBER.$i
#   stopprofilers $i
#   doprofilers report $i
# done
#
# for ((i=1;i<=$ARG1;i++)); do
#   doprofilers postprocess $i
# done
# 

# For an example of a benchmark which does it's own internal warmup, and 
# cooldown phase, look at the specjbb script to see how to manage the profilers
# correctly.


# Clean up ###################################################################
popd > /dev/null
