#!/bin/bash
# This is template profiler script
#
# reqparam value start|stop|report|postprocess|install Which action you'd like to perform
# reqparam value Any required arguments
# optparam value Any options arguments
# optparam value Suffix - an optional string to append to the name of the log file
# (The last argument is always an optional suffix to output files)
#

. /etc/autobench.conf || . functions

if [ $# -lt 1 ]; then
  echo "You must specify start, stop, report, postprocess, or install"
  exit 1
fi

CMD="`echo $1 | tr -t A-Z a-z`"

# Check for required arguments.

#if [ $# -lt 2 ]; then
#  echo "You must specify an argument"
#  exit 1
#fi

if [ $# -eq 3 ]; then
  SUFFIX=".$3"
fi

case $CMD in
  install)
    # Check to see if the required software is installed, if not install it
    # support software should go into $AUTODIR/sources/
    # This will often look like:
    # if [ ! -e $AUTODIR/sources/PROFILER_NAME ]; then
    #   $AUTODIR/scripts/profilers/install/PROFILER_NAME
    # fi
    ;;
  start)
    # Start the profiler
    # Profiler output usually goes to
    # $LOGDIR/analysis/PROFILER_NAME.$RUN_NUMBER$SUFFIX
    ;;

  print-start)
    # Print a minimal set of commands to start the profiler.
    # This is so the profiler can be started quickly in the case of running
    # multiple profilers
    ;;

  stop)
    # Stop the profiler
    ;;

  print-stop)
    # Print a minimal set of commands to stop the profiler.
    ;;

  report)
    # Any command necessary to preserve the profiler output before another
    # iteration of the test is run.  (i.e. readprofile has a stop command,
    # but a file has to be copied out of proc to preserve the output before
    # the next run)  Another benchmark run will occur shortly, so we only 
    # want to do the minimum of work that we can get away with here.
    ;;

  postprocess)
    # Any commands needed to postprocesses the results.
    # The test has completed.  Now we can spend as much time as we need to
    # postprocess the results.
    ;;

  *)
    echo "The first argument must be start, stop, report, postprocess, or install"
    ;;
esac

