101-testing-timeit.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. --- a/testing/timeit.sh
  2. +++ b/testing/timeit.sh
  3. @@ -1,11 +1,8 @@
  4. #!/bin/bash
  5. -# "man 1 time" for details
  6. -export TIME="%U seconds"
  7. -
  8. add()
  9. {
  10. - if ! dc -e ""; then
  11. + if ! dc p >/dev/null 2>&1; then
  12. echo you do not have dc, so I cannot add these numbers...
  13. exit 1
  14. fi
  15. @@ -14,7 +11,7 @@ add()
  16. tot=0
  17. while read n; do
  18. - tot=`dc -e "$n $tot + pop" 2> /dev/null`
  19. + tot=`dc $n $tot + p 2> /dev/null`
  20. done
  21. echo $tot seconds
  22. @@ -34,7 +31,7 @@ extract()
  23. if [ ! $3 ] || [ $2 == "-h" ] || [ $2 == "--help" ]; then
  24. echo
  25. - echo Syntax: ./timeit.sh patternfile kernel\|userspace all\|print\|real [data_files]
  26. + echo Syntax: .//usr/bin/timeit.sh patternfile kernel\|userspace all\|print\|real [data_files]
  27. echo
  28. echo \"kernel\" uses the kernel pattern and library
  29. echo \"userspace\" uses userspace pattern and library
  30. @@ -72,12 +69,12 @@ echo Timing $1
  31. if [ $3 == "all" ]; then
  32. echo Using all characters
  33. if [ $2 == "kernel" ]; then
  34. - if ! ./randchars | time $speedprog "`extract $1`" verbose; then
  35. + if ! ./randchars | /usr/bin/time $speedprog "`extract $1`" verbose 2>&1 >/dev/null | grep user | cut -d\ -f2; then
  36. echo $speedprog failed. > /dev/stderr
  37. exit 1
  38. fi
  39. else
  40. - if ! ./randchars | time $speedprog -f "$1" -v; then
  41. + if ! ./randchars | /usr/bin/time $speedprog -f "$1" -v 2>&1 >/dev/null | grep user | cut -d\ -f2; then
  42. echo $speedprog failed. > /dev/stderr
  43. exit 1
  44. fi
  45. @@ -85,12 +82,12 @@ if [ $3 == "all" ]; then
  46. elif [ $3 == "print" ]; then
  47. echo Using only printable characters
  48. if [ $2 == "kernel" ]; then
  49. - if ! ./randprintable | time $speedprog "`extract $1`" verbose; then
  50. + if ! ./randprintable | /usr/bin/time $speedprog "`extract $1`" verbose 2>&1 >/dev/null | grep user | cut -d\ -f2; then
  51. echo $speedprog failed. > /dev/stderr
  52. exit 1
  53. fi
  54. else
  55. - if ! ./randprintable | time $speedprog -f "$1" -v; then
  56. + if ! ./randprintable | /usr/bin/time $speedprog -f "$1" -v 2>&1 >/dev/null | grep user | cut -d\ -f2; then
  57. echo $speedprog failed. > /dev/stderr
  58. exit 1
  59. fi
  60. @@ -107,12 +104,12 @@ elif [ $3 == "real" ]; then
  61. printf $f\\t
  62. #echo `extract $1`
  63. if [ $2 == "kernel" ]; then
  64. - if ! cat $f | time $speedprog "`extract $1`" 2> /dev/stdout | tee -a tmp.$$; then
  65. + if ! cat $f | /usr/bin/time $speedprog "`extract $1`" 2>&1 >/dev/null | grep user | cut -d\ -f2 | tee -a tmp.$$; then
  66. echo $speedprog failed. > /dev/stderr
  67. exit 1
  68. fi
  69. else
  70. - if ! cat $f | time $speedprog -f "$1" 2> /dev/stdout | tee -a tmp.$$; then
  71. + if ! cat $f | /usr/bin/time $speedprog -f "$1" 2>&1 >/dev/null | grep user | cut -d\ -f2 | tee -a tmp.$$; then
  72. echo $speedprog failed. > /dev/stderr
  73. exit 1
  74. fi
  75. @@ -123,12 +120,12 @@ elif [ $3 == "real" ]; then
  76. for f in data/*; do
  77. printf $f\\t
  78. if [ $2 == "kernel" ]; then
  79. - if ! cat $f | time $speedprog "`extract $1`" 2> /dev/stdout | tee -a tmp.$$; then
  80. + if ! cat $f | /usr/bin/time $speedprog "`extract $1`" 2>&1 >/dev/null | grep user | cut -d\ -f2 | tee -a tmp.$$; then
  81. echo $speedprog failed. > /dev/stderr
  82. exit 1
  83. fi
  84. else
  85. - if ! cat $f | time $speedprog -f "$1" 2> /dev/stdout | tee -a tmp.$$; then
  86. + if ! cat $f | /usr/bin/time $speedprog -f "$1" 2>&1 >/dev/null | grep user | cut -d\ -f2 | tee -a tmp.$$; then
  87. echo $speedprog failed. > /dev/stderr
  88. exit 1
  89. fi
  90. @@ -137,7 +134,7 @@ elif [ $3 == "real" ]; then
  91. fi
  92. printf Total:\
  93. - cat tmp.$$ | cut -d\ -f 2 | add
  94. + cat tmp.$$ | cut -ds -f 1| add
  95. rm tmp.$$
  96. else