123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- --- a/testing/timeit.sh
- +++ b/testing/timeit.sh
- @@ -1,11 +1,8 @@
- #!/bin/bash
-
- -# "man 1 time" for details
- -export TIME="%U seconds"
- -
- add()
- {
- - if ! dc -e ""; then
- + if ! dc p >/dev/null 2>&1; then
- echo you do not have dc, so I cannot add these numbers...
- exit 1
- fi
- @@ -14,7 +11,7 @@ add()
- tot=0
-
- while read n; do
- - tot=`dc -e "$n $tot + pop" 2> /dev/null`
- + tot=`dc $n $tot + p 2> /dev/null`
- done
-
- echo $tot seconds
- @@ -34,7 +31,7 @@ extract()
-
- if [ ! $3 ] || [ $2 == "-h" ] || [ $2 == "--help" ]; then
- echo
- - echo Syntax: ./timeit.sh patternfile kernel\|userspace all\|print\|real [data_files]
- + echo Syntax: .//usr/bin/timeit.sh patternfile kernel\|userspace all\|print\|real [data_files]
- echo
- echo \"kernel\" uses the kernel pattern and library
- echo \"userspace\" uses userspace pattern and library
- @@ -72,12 +69,12 @@ echo Timing $1
- if [ $3 == "all" ]; then
- echo Using all characters
- if [ $2 == "kernel" ]; then
- - if ! ./randchars | time $speedprog "`extract $1`" verbose; then
- + if ! ./randchars | /usr/bin/time $speedprog "`extract $1`" verbose 2>&1 >/dev/null | grep user | cut -d\ -f2; then
- echo $speedprog failed. > /dev/stderr
- exit 1
- fi
- else
- - if ! ./randchars | time $speedprog -f "$1" -v; then
- + if ! ./randchars | /usr/bin/time $speedprog -f "$1" -v 2>&1 >/dev/null | grep user | cut -d\ -f2; then
- echo $speedprog failed. > /dev/stderr
- exit 1
- fi
- @@ -85,12 +82,12 @@ if [ $3 == "all" ]; then
- elif [ $3 == "print" ]; then
- echo Using only printable characters
- if [ $2 == "kernel" ]; then
- - if ! ./randprintable | time $speedprog "`extract $1`" verbose; then
- + if ! ./randprintable | /usr/bin/time $speedprog "`extract $1`" verbose 2>&1 >/dev/null | grep user | cut -d\ -f2; then
- echo $speedprog failed. > /dev/stderr
- exit 1
- fi
- else
- - if ! ./randprintable | time $speedprog -f "$1" -v; then
- + if ! ./randprintable | /usr/bin/time $speedprog -f "$1" -v 2>&1 >/dev/null | grep user | cut -d\ -f2; then
- echo $speedprog failed. > /dev/stderr
- exit 1
- fi
- @@ -107,12 +104,12 @@ elif [ $3 == "real" ]; then
- printf $f\\t
- #echo `extract $1`
- if [ $2 == "kernel" ]; then
- - if ! cat $f | time $speedprog "`extract $1`" 2> /dev/stdout | tee -a tmp.$$; then
- + if ! cat $f | /usr/bin/time $speedprog "`extract $1`" 2>&1 >/dev/null | grep user | cut -d\ -f2 | tee -a tmp.$$; then
- echo $speedprog failed. > /dev/stderr
- exit 1
- fi
- else
- - if ! cat $f | time $speedprog -f "$1" 2> /dev/stdout | tee -a tmp.$$; then
- + if ! cat $f | /usr/bin/time $speedprog -f "$1" 2>&1 >/dev/null | grep user | cut -d\ -f2 | tee -a tmp.$$; then
- echo $speedprog failed. > /dev/stderr
- exit 1
- fi
- @@ -123,12 +120,12 @@ elif [ $3 == "real" ]; then
- for f in data/*; do
- printf $f\\t
- if [ $2 == "kernel" ]; then
- - if ! cat $f | time $speedprog "`extract $1`" 2> /dev/stdout | tee -a tmp.$$; then
- + if ! cat $f | /usr/bin/time $speedprog "`extract $1`" 2>&1 >/dev/null | grep user | cut -d\ -f2 | tee -a tmp.$$; then
- echo $speedprog failed. > /dev/stderr
- exit 1
- fi
- else
- - if ! cat $f | time $speedprog -f "$1" 2> /dev/stdout | tee -a tmp.$$; then
- + if ! cat $f | /usr/bin/time $speedprog -f "$1" 2>&1 >/dev/null | grep user | cut -d\ -f2 | tee -a tmp.$$; then
- echo $speedprog failed. > /dev/stderr
- exit 1
- fi
- @@ -137,7 +134,7 @@ elif [ $3 == "real" ]; then
- fi
-
- printf Total:\
- - cat tmp.$$ | cut -d\ -f 2 | add
- + cat tmp.$$ | cut -ds -f 1| add
-
- rm tmp.$$
- else
|