diff options
author | André Nusser <andre.nusser@googlemail.com> | 2016-02-03 19:14:23 +0100 |
---|---|---|
committer | André Nusser <andre.nusser@googlemail.com> | 2016-02-03 19:14:23 +0100 |
commit | 9aa7d527ae99c38992b0d8289e46d233bab87f64 (patch) | |
tree | 24326e50d6f9323aef466df8fd5947c25b730744 | |
parent | 72618685689a652db5a2ac98ce6ba53c43568008 (diff) |
Fix last sample in performance test script.
-rwxr-xr-x | tools/performance_test/performance_test.sh | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/tools/performance_test/performance_test.sh b/tools/performance_test/performance_test.sh index 984d6b4..8e69e31 100755 --- a/tools/performance_test/performance_test.sh +++ b/tools/performance_test/performance_test.sh @@ -99,23 +99,27 @@ function logData top_output_labels="$(top -b -n 1 -p $pid | grep "^[ ]*PID")" top_output_values="$(top -b -n 1 -p $pid | grep "^[ ]*$pid")" - top_arr=($top_output_values) - cpu_pos=$(get_position "%CPU" "$top_output_labels") - ram_pos=$(get_position "%MEM" "$top_output_labels") - - if [ "$cpu_pos" == "-1" ] || [ "$ram_pos" == "-1" ] + if [ "$top_output_values" != "" ] then - echo "The top output doesn't look like expected." - echo "Exiting..." - exit - fi + top_arr=($top_output_values) - cpu_usage="${top_arr[$cpu_pos]}" - ram_usage="${top_arr[$ram_pos]}" + cpu_pos=$(get_position "%CPU" "$top_output_labels") + ram_pos=$(get_position "%MEM" "$top_output_labels") - cpu_data="${cpu_data}${time_elapsed} ${cpu_usage}\n" - ram_data="${ram_data}${time_elapsed} ${ram_usage}\n" + if [ "$cpu_pos" == "-1" ] || [ "$ram_pos" == "-1" ] + then + echo "The top output doesn't look like expected." + echo "Exiting..." + exit + fi + + cpu_usage="${top_arr[$cpu_pos]}" + ram_usage="${top_arr[$ram_pos]}" + + cpu_data="${cpu_data}${time_elapsed} ${cpu_usage}\n" + ram_data="${ram_data}${time_elapsed} ${ram_usage}\n" + fi avg_cpu_usage_candidate="$(ps -p $pid -o %cpu | grep "^[ ]*[0-9][0-9]*")" # to make sure the process was still running when we executed the last command |