From 9aa7d527ae99c38992b0d8289e46d233bab87f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Wed, 3 Feb 2016 19:14:23 +0100 Subject: Fix last sample in performance test script. --- tools/performance_test/performance_test.sh | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'tools') 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 -- cgit v1.2.3