#!/bin/sh

rm outS
for x in 100k 200k 400k 800k 1600k 3200k 6400k 12800k 25600k 51200k 102400k 204800k
do
  for y in 0 1 2 3
  do 
    echo ./simstr IGw -f 10 -s 2 X."$x" 30 $y out
    time -p (./simstr IGw -f 10 -s 2 X."$x" 30 $y out ) > outt 2>&1 & 
    pid=$!
    a=0
    flag=""
    while [ $a -le 3600 ]
    do
      w=`pmap $pid`
      if [ -z "$w" ] ; then
        flag=1
        a=40000000
      fi
      a=`expr $a + 1`
      sleep 1
    done
    
    if [ -n "$flag" ] ; then
      echo -n X."$x"_"$y" " " >> outS
      fgrep user outt | awk '{print $2}' >> outS
      n=`wc out | tail -1 | awk '{print $1}'`
      l=`ls -l out | awk '{print $5}'`
      echo $n " " $l " " `expr $l / $n` >> outS
    else 
      pkill simstr
    fi
  done
done


for x in 25k 50k 100k 200k 400k 800k 1600k 3200k 4700k
do
  for y in 0 1 2
  do
    echo ./simstr32 Itw -f 10 -s 2 word."$x" 12 $y out
    time -p (./simstr Itw -f 10 -s 2 word."$x" 12 $y out ) > outt 2>&1 & 
    pid=$!
    a=0
    flag=""
    while [ $a -le 3600 ]
    do
      w=`pmap $pid`
      if [ -z "$w" ] ; then
        flag=1
        a=40000000
      fi
      a=`expr $a + 1`
      sleep 1
    done
    
    if [ -n "$flag" ] ; then
      echo -n word."$x"_"$y" " " >> outS
      fgrep user outt | awk '{print $2}' >> outS
      n=`wc out | tail -1 | awk '{print $1}'`
      l=`ls -l out | awk '{print $5}'`
      echo $n " " $l " " `expr $l / $n` >> outS
    else 
      pkill simstr
    fi
  done
done
