1
0

perf_test.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/sh
  2. ## Copyright (c) 2015 Minoca Corp.
  3. ##
  4. ## This file is licensed under the terms of the GNU General Public License
  5. ## version 3. Alternative licensing terms are available. Contact
  6. ## info@minocacorp.com for details. See the LICENSE file at the root of this
  7. ## project for complete licensing information..
  8. ##
  9. ## Script Name:
  10. ##
  11. ## perf_test.sh
  12. ##
  13. ## Abstract:
  14. ##
  15. ## This script runs the performance benchmark test.
  16. ##
  17. ## Author:
  18. ##
  19. ## Chris Stevens 4-May-2015
  20. ##
  21. ## Environment:
  22. ##
  23. ## Minoca Build
  24. ##
  25. set -e
  26. export TMPDIR=$PWD
  27. export TEMP=$TMPDIR
  28. PERF_TEST=../../testbin/perftest
  29. CLIENT=../../client.py
  30. CPU_INFO=../../tasks/test/cpu_info.py
  31. uname -a
  32. ##
  33. ## Run the performance test with a single process.
  34. ##
  35. results_file=perf_results.txt
  36. if test $1; then
  37. duration="-d $1"
  38. echo "Running all performance tests with 1 process for $1 second(s)."
  39. else
  40. duration=""
  41. echo "Running all performance tests with 1 process for their default durations."
  42. fi
  43. ./$PERF_TEST $duration -s -r $results_file
  44. echo "Done running all performance tests with 1 process."
  45. ##
  46. ## Push the results. Each line was already formatted as a result.
  47. ##
  48. SAVED_IFS="$IFS"
  49. IFS=':'
  50. while read line; do
  51. python $CLIENT --result $line
  52. done < $results_file
  53. IFS="$SAVED_IFS"
  54. rm $results_file
  55. ##
  56. ## Get the number of cores on the system. Skip the multi-process test if the
  57. ## number of cores could not be determined or if there is only 1 core.
  58. ##
  59. cpu_count=`python $CPU_INFO --count`
  60. if [ -z $cpu_count ] ||
  61. [ "x$cpu_count" = "xunknown" ] ||
  62. [ "x$cpu_count" = "x1" ]; then
  63. exit 0
  64. fi
  65. ##
  66. ## Run each performance test in parallel with N processes, where N is the
  67. ## number of cores on the system.
  68. ##
  69. results_file=perf_multi_results.txt
  70. if test $1; then
  71. duration="-d $1"
  72. echo "Running all performance tests with $cpu_count processes for $1 second(s)."
  73. else
  74. duration=""
  75. echo "Running all performance tests with $cpu_count processes for their default durations."
  76. fi
  77. ./$PERF_TEST $duration -p $cpu_count -s -r $results_file
  78. echo "Done running all performance tests with $cpu_count processes."
  79. ##
  80. ## Push the results. Each line was already formatted as a result.
  81. ##
  82. SAVED_IFS="$IFS"
  83. IFS=':'
  84. while read line; do
  85. python $CLIENT --result $line
  86. done < $results_file
  87. IFS="$SAVED_IFS"
  88. rm $results_file