1
0

perf_test.sh 2.0 KB

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