#!/bin/bash

########################
# Function definitions #
########################

source "$(dirname $0)/measurement-functions"

########################
# Script body          #
########################

DRD_SCRIPTS_DIR="$(dirname $0)"
if [ "${DRD_SCRIPTS_DIR:0:1}" != "/" ]; then
  DRD_SCRIPTS_DIR="$PWD/$DRD_SCRIPTS_DIR"
fi

VG="${DRD_SCRIPTS_DIR}/../../vg-in-place"
MATINV="${DRD_SCRIPTS_DIR}/../../drd/tests/matinv"


for n in 200 400
do
  tmp="/tmp/test-timing.$$"
  rm -f "${tmp}"

  measure_runtime ${MATINV} $n | avgstddev > "$tmp"
  read avg1 stddev1 vsz1 vszdev1 < "$tmp"
  echo "Average time: ${avg1} +/- ${stddev1} seconds." \
       " VSZ: ${vsz1} +/- ${vszdev1} KB"

  for i in 1 10
  do
    print_runtime_ratio ${avg1} ${stddev1} ${vsz1} ${vszdev1} \
      ${VG} --tool=none    ${MATINV} $n -t$i
    print_runtime_ratio ${avg1} ${stddev1} ${vsz1} ${vszdev1} \
      ${VG} --tool=drd ${MATINV} $n -t$i
  done
done
