#!/bin/bash

blah=""
runs=25

target=tempsized

#trusted is concidered the reference copy
trusted_ext=gift-extract-features
trusted_wri=gift-write-feature-descs

#untrusted is the version we're testing
untrusted_ext=/disk1/gift/src/merge/dev/gift/FeatureExtraction/gift-extract-features
#untrusted_wri=gift-write-feature-descs
untrusted_wri=/disk1/gift/src/merge/dev/gift/FeatureExtraction/gift-write-feature-descs


#first, generate "origional trusted" versions of our two data files ($target.fts, InvertedFileFeatureDescription.db)
time $trusted_ext $target.ppm
mv $target.fts orig_$target.fts

$trusted_wri 18 3 3 4 < $target.ppm > orig_InvertedFileFeatureDescription.db

#now, timing test our feature extractor, doing a diff for comparison each iteration

for ((i=0;i<runs;i++)); do 
    {
	/usr/bin/time -o blah.out $untrusted_ext $target.ppm
	blah="$blah`cat blah.out | sed -n \"/^[0-9.]*user/p\" | sed \"s/^0*\([0-9.]*\).*/\1+/\" | tr -d \"\n\"`"
	diff -a $target.fts orig_$target.fts
	echo $blah
    } 
done

#report our result

echo -n $blah=" "
echo "scale=5; $blah" | sed "s/.$//" | bc	
bleh=`echo "scale=5; $blah" | sed "s/.$//" | bc`	
echo -n "magic number: "

echo "scale=5; $bleh / $runs " | bc

blah=""
bleh=""
runs=""

#next, test our write-feature-descs
$untrusted_wri 18 3 3 4 < $target.ppm > untrusted_InvertedFileFeatureDescription.db
diff -a untrusted_InvertedFileFeatureDescription.db orig_InvertedFileFeatureDescription.db