#!/bin/sh
cd "`dirname $0`"
[ -d tmp ] || mkdir tmp
cd tmp
for stats in restarts conflicts decisions simplifying search bump decide
do
  case $stats in
    restarts|conflicts|decisions) pattern="$stats,";pos=2;;
    simplifying|search|bump|decide) pattern="$stats"'$';pos=2;;
  esac
  [ -d $stats ] || mkdir $stats
  cd $stats
  configs="evsids vmtf acids vsids sum inc static"
  configs="$configs heap queue"
  for config in $configs
  do
    echo "$stats $config"
    grep "$pattern" ../../../*logs/$config/*.log|awk "{print \$$pos}"|sort -n > $config
  done
  rm -f script
  if false
  then
    echo "set output \"../../${stats}.eps\"" >>script
    echo "set terminal postscript enhanced color" >>script
  else
    echo "set output \"../../${stats}.pdf\"" >>script
    echo "set terminal pdf" >>script
  fi
  echo "set key left" >>script
  echo "set title \"$stats\"" >>script
  #echo "set log y" >>script
  first=yes
  for config in $configs
  do
    if [ $first = yes ]
    then
      first=no
      echo -n "plot" >>script
    else
      echo -n "," >>script
    fi
    echo -n " \"$config\" title \"$config\"" >>script
  done
  echo >>script
  gnuplot script
  cd ..
done
