Test script outputs in CSV
authorKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 22 Mar 2018 00:42:26 +0000 (18:42 -0600)
committerKevin M. Rosenberg <kevin@rosenberg.net>
Thu, 22 Mar 2018 00:42:26 +0000 (18:42 -0600)
scripts/make-single-openmp.sh [deleted file]
scripts/test-single-openmp.sh [deleted file]
tests/make-single-openmp.sh [new file with mode: 0755]
tests/test-single-openmp.sh [new file with mode: 0755]

diff --git a/scripts/make-single-openmp.sh b/scripts/make-single-openmp.sh
deleted file mode 100755 (executable)
index 5e9ead1..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-DIR=/tmp
-rm -rf $DIR/sng $DIR/omp
-mkdir $DIR/sng $DIR/omp
-
-(cd ..; (make clean > /dev/null); (./configure --disable-openmp > /dev/null); grep HAVE_OPEN config.h; (make -j 20 > /dev/null); cp tools/ctsimtext src/ctsim $DIR/sng/.)
-(cd ..; (make clean > /dev/null); (./configure --enable-openmp > /dev/null); grep HAVE_OPEN config.h; (make -j 20 > /dev/null); cp tools/ctsimtext src/ctsim $DIR/omp/.)
diff --git a/scripts/test-single-openmp.sh b/scripts/test-single-openmp.sh
deleted file mode 100755 (executable)
index c6d88da..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-#/bin/sh
-
-TEST=short
-if test $# -ge 1; then
-    TEST=$1
-fi
-
-if test "x$TEST" = "xshort"; then
-    PR=165;  PV=144;  IX=115;  IY=$IX
-elif test "x$TEST" = "xmedium"; then
-    PR=901;  PV=600;  IX=500;  IY=$IX
-elif test "x$TEST" = "xlong"; then
-    PR=1651;  PV=1440;  IX=1151;  IY=$IX
-else
-    echo "usage: $0 [test-size]"
-    echo "test-size -- either short, medium, or long"
-    exit
-fi
-TIME=
-
-DIR=/tmp
-BIN1=$DIR/omp/ctsimtext
-BIN2=$DIR/sng/ctsimtext
-
-for PHAN in herman; do
-    for GEOM in equilinear equiangular parallel; do
-        echo "$PHAN $GEOM"
-        echo "-------------------"
-        fbase=${DIR}/${PHAN}-${GEOM}
-        rm -f ${fbase}-*
-
-        echo -n "$BIN1 Proj: "; $TIME $BIN1 phm2pj $fbase-omp.pj $PR $PV --phantom $PHAN --verbose | tail -1  | sed 's/Run time: (.+) /$1/'
-        echo -n "$BIN2 Proj: "; $TIME $BIN2 phm2pj $fbase-sng.pj $PR $PV --phantom $PHAN --verbose | tail -1 | sed 's/Run time: (.+) /$1/'
-        echo
-
-        for BP in idiff diff table trig; do
-            for INT in nearest linear cubic; do
-                recbase=${fbase}-${BP}-${INT}
-                echo -n "$BIN1 Recon $BP $INT: "; $TIME $BIN1 pjrec $fbase-omp.pj $recbase-omp.if $IX $IY --verbose --interp $INT --backproj $BP | tail -1
-                echo -n "$BIN2 Recon $BP $INT: "; $TIME $BIN2 pjrec $fbase-sng.pj $recbase-sng.if $IX $IY --verbose --interp $INT --backproj $BP| tail -1
-                echo -n "--> Difference Recon $BP $INT: "; $BIN1 if2 $recbase-omp.if $recbase-sng.if --comp
-                echo
-            done
-        done
-    done
-    phmbase=${fbase}-phm
-    echo -n "$BIN1 Phm: "; $TIME $BIN1 phm2if ${phmbase}-omp.if $IX $IX --phantom $PHAN --nsample 5 --verbose | tail -1
-    echo -n "$BIN2 Phm: "; $TIME $BIN2 phm2if ${phmbase}-sng.if $IX $IX --phantom $PHAN --nsample 5 --verbose | tail -1
-    echo -n "--> Image diff Phantom: "; $BIN1 if2 ${phmbase}-omp.if ${phmbase}-sng.if --comp
-    echo
-done
diff --git a/tests/make-single-openmp.sh b/tests/make-single-openmp.sh
new file mode 100755 (executable)
index 0000000..5e9ead1
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+DIR=/tmp
+rm -rf $DIR/sng $DIR/omp
+mkdir $DIR/sng $DIR/omp
+
+(cd ..; (make clean > /dev/null); (./configure --disable-openmp > /dev/null); grep HAVE_OPEN config.h; (make -j 20 > /dev/null); cp tools/ctsimtext src/ctsim $DIR/sng/.)
+(cd ..; (make clean > /dev/null); (./configure --enable-openmp > /dev/null); grep HAVE_OPEN config.h; (make -j 20 > /dev/null); cp tools/ctsimtext src/ctsim $DIR/omp/.)
diff --git a/tests/test-single-openmp.sh b/tests/test-single-openmp.sh
new file mode 100755 (executable)
index 0000000..9eea4da
--- /dev/null
@@ -0,0 +1,58 @@
+#/bin/bash
+
+TEST=short
+if test $# -ge 1; then
+    TEST=$1
+fi
+
+if test "x$TEST" = "xshort"; then
+    PR=165;  PV=144;  IX=115;  IY=$IX
+    NSAMPLE=2
+elif test "x$TEST" = "xmedium"; then
+    PR=901;  PV=600;  IX=500;  IY=$IX
+    NSAMPLE=4
+elif test "x$TEST" = "xlong"; then
+    PR=1651;  PV=1440;  IX=1151;  IY=$IX
+    NSAMPLE=5
+else
+    echo "usage: $0 [test-size]"
+    echo "test-size -- either short, medium, or long"
+    exit
+fi
+TIME=
+
+DIR=/tmp
+BIN_SNG=$DIR/sng/ctsimtext
+BIN_OMP=$DIR/omp/ctsimtext
+
+RUNTIME_REGEX="sed -r 's/^[^0-9]* ([0-9\.]+)[ a-z]*/\1/'"
+for PHAN in herman; do
+    fbase=${DIR}/${PHAN}
+    phmbase=$fbase
+    rm -rf ${phmbase}-*
+
+    ts=`sh -c "$BIN_SNG phm2if ${phmbase}-sng.if $IX $IY --phantom $PHAN --nsample $NSAMPLE --verbose | tail -1 | $RUNTIME_REGEX"`
+    tm=`sh -c "$BIN_OMP phm2if ${phmbase}-omp.if $IX $IY --phantom $PHAN --nsample $NSAMPLE --verbose | tail -1 | $RUNTIME_REGEX"`
+    ratio=`bc <<< "scale=2; $ts / $tm"`
+    diff=`$BIN_SNG if2 ${phmbase}-omp.if ${phmbase}-sng.if --comp`
+    echo "Phantom,$PHAN,$tm,$ts,$ratio,\"$diff\""
+
+    for GEOM in equilinear equiangular parallel; do
+        ifbase=${phmbase}-${GEOM}
+        ts=`sh -c "$BIN_SNG phm2pj ${ifbase}-sng.pj $PR $PV --phantom $PHAN --verbose | tail -1 | $RUNTIME_REGEX"`
+        tm=`sh -c "$BIN_OMP phm2pj ${ifbase}-omp.pj $PR $PV --phantom $PHAN --verbose | tail -1 | $RUNTIME_REGEX"`
+        ratio=`bc <<< "scale=2; $ts / $tm"`
+        echo "Projection,$PHAN,$GEOM,$tm,$ts,$ratio"
+
+        for BP in idiff diff table trig; do
+            for INT in nearest linear cubic; do
+                recbase=${ifbase}-${BP}-${INT}
+                ts=`sh -c "$BIN_SNG pjrec ${ifbase}-sng.pj $recbase-sng.if $IX $IY --verbose --interp $INT --backproj $BP | tail -1 | $RUNTIME_REGEX"`
+                tm=`sh -c "$BIN_OMP pjrec ${ifbase}-omp.pj $recbase-omp.if $IX $IY --verbose --interp $INT --backproj $BP | tail -1 | $RUNTIME_REGEX"`
+                ratio=`bc <<< "scale=2; $ts / $tm"`
+                diff=`$BIN_SNG if2 $recbase-omp.if $recbase-sng.if --comp`
+                echo "Reconstruction,$PHAN,$GEOM,$BP,$INT,$tm,$ts,$ratio,\"$diff\""
+            done
+        done
+    done
+done