#!/bin/bash -e

# generate list.txt using random data
f=list.txt
test -f $f || ./gen_cvs2.awk

#./gen_cvs.exe

true <$f || exit

lines=`wc -l < $f`
bytes=`wc -c < $f`

#scalc() { calc -d "display(6),config(\"tab\",0),$1"; }
scalc() { gawk "BEGIN { print $1; }"; }

for i in test_awk.sh test_hans.exe test_foobar2.exe
do
    n1=$EPOCHREALTIME; ./$i; n2=$EPOCHREALTIME

    tm=`scalc "$n2 - $n1"` 
    bps=`scalc "$bytes / ($n2 - $n1) * 1e-6"`
    lps=`scalc "$lines / ($n2 - $n1) * 1e0"`

    printf '%-20s Seconds=%-6.2f MB/sec=%-6.2f Lines/sec=%-6.0f\n' $i $tm $bps $lps
done

#diff nodup.txt nodup3.txt
#diff nodup.txt nodup4.txt
