+while getopts "h?ac:f:i:nt:" opt; do
+ case "$opt" in
+ h|\?)
+ usage
+ exit 1
+ ;;
+ a) auth=true
+ ;;
+ c) cycles=$OPTARG
+ ;;
+ f) flows=$OPTARG
+ ;;
+ i) instances=$OPTARG
+ ;;
+ n) no_delete=true
+ ;;
+ t) threads=$OPTARG
+ ;;
+ esac
+done
+
+echo "Running $instances instance(s), parameters:\n flows='flows', threads=$threads, cycles=$cycles, \
+no-delete='$no_delete', auth='$auth'"
+
+
+let "flows_per_instance=$cycles * $flows * $threads"
+
+printf "FPI: %d\n" $flows_per_instance
+
+i=0
+START_TIME=$SECONDS
+while [ $i -lt $instances ]; do
+ let "startflow=$flows_per_instance * $i"
+
+ CMD_STRING=$(printf '%s --cycles %s --flows %s --threads %s --startflow %s' $CMD $cycles $flows $threads $startflow)
+ if [ "$auth" = true ] ; then
+ CMD_STRING+=' --auth'
+ fi
+ if [ "$no_delete" = true ] ; then
+ CMD_STRING+=' --no-delete'
+ fi
+
+ echo "Starting instance $i: '$CMD_STRING'"
+ let i=$i+1
+ $CMD_STRING &
+done
+
+wait
+ELAPSED_TIME=$(($SECONDS - $START_TIME))
+
+let "rate=($flows_per_instance * $instances)/$ELAPSED_TIME"