From 9310177b736ddf8c6599f685cd38191a95933202 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Sun, 31 Jan 2016 23:10:30 +0100 Subject: Give the test scripts a '.sh' ending. Small improvements to perf. test. --- tools/performance_test/performance_test | 126 ----------------------- tools/performance_test/performance_test.gnuplot | 2 +- tools/performance_test/performance_test.sh | 129 ++++++++++++++++++++++++ tools/valgrind_test/valgrind_test | 66 ------------ tools/valgrind_test/valgrind_test.sh | 66 ++++++++++++ 5 files changed, 196 insertions(+), 193 deletions(-) delete mode 100755 tools/performance_test/performance_test create mode 100755 tools/performance_test/performance_test.sh delete mode 100755 tools/valgrind_test/valgrind_test create mode 100755 tools/valgrind_test/valgrind_test.sh (limited to 'tools') diff --git a/tools/performance_test/performance_test b/tools/performance_test/performance_test deleted file mode 100755 index 608b3ea..0000000 --- a/tools/performance_test/performance_test +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# USAGE: ./performance_test -# This script needs JACK to be started or just starts it itself if it isn't. - -test_dir=$(dirname $0) -cd $test_dir - -dg_path="../../drumgizmo" -sample_interval=.5 -cpu_plot_file="cpu_plot" -ram_plot_file="ram_plot" -cpu_data_file="cpu_data.dat" -ram_data_file="ram_data.dat" - -# check for right number of parameters -if [[ $# != 3 ]] -then - echo "ERROR: You didn't supply the right number of parameters." - echo "USAGE: ./performance_test " - echo "Exiting..." - exit -fi - -kit="$1" -midimap="$2" -midifile="$3" - -# function to check for dependencies -function check_for_deps -{ - for dep in "$@" - do - if ! command -v $dep >/dev/null 2>&1 - then - echo "ERROR: Cannot find ${dep}. Maybe it isn't installed?" - echo "Exiting..." - exit - fi - done -} - -# check for drumgizmo -if ! [ -e $dg_path/drumgizmo ] -then - echo "ERROR: The drumgizmo binary doesn't exist. Maybe you forgot to compile?" - echo "Exiting..." - exit -fi - -# check for dependencies -check_for_deps gnuplot top awk - -# check for the existence of the passed files -if ! [ -e "$1" ] || ! [ -e "$2" ] || ! [ -e "$3" ] -then - echo "ERROR: One of the files (kit/midimap/midfile) doesn't exist." - echo "Exiting..." - exit -fi - -echo "============================" -echo "Starting the performace test" -echo "============================" - -# initial data values -cpu_data="" -ram_data="" -avg_cpu_usage="" -time_elapsed=0 - -# log ram and cpu usage of process -function logData -{ - pid=$1 - - top_output="$(top -b -n 1 -p $pid | grep "^[ ]*$pid")" - top_arr=($top_output) - - cpu_usage="${top_arr[6]}" - ram_usage="${top_arr[7]}" - - cpu_data="${cpu_data}${time_elapsed} ${cpu_usage}\n" - ram_data="${ram_data}${time_elapsed} ${ram_usage}\n" - - 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 - if [ avg_cpu_usage_candidate != "" ]; then avg_cpu_usage=$avg_cpu_usage_candidate; fi - - # hack to allow for float addition in the bash - time_elapsed="$(awk "BEGIN {print $time_elapsed+$sample_interval; exit}")" -} - -# gnuplot ram and cpu usage over time -function plotData -{ - echo -e "$cpu_data" > $cpu_data_file - echo -e "$ram_data" > $ram_data_file - gnuplot performance_test.gnuplot > /dev/null 2>&1 -} - -# start dg -echo $kit -$dg_path/./drumgizmo -i midifile -I file="$midifile",midimap="$midimap" -o jackaudio "$kit" & -pid=$! - -# collect data while dg is running -while ps -p $pid > /dev/null -do - logData $pid - sleep $sample_interval -done - -# plot data -plotData - -echo -echo "-------------------------------------------------------------------" -echo "The average CPU usage was: ${avg_cpu_usage}%" -echo "See the data files $cpu_data_file and $ram_data_file for details." -echo "They are nicely plotted in cpu_data.png and ram_data.png." -echo "-------------------------------------------------------------------" -echo - -echo "============================" -echo "Finished the performace test" -echo "============================" diff --git a/tools/performance_test/performance_test.gnuplot b/tools/performance_test/performance_test.gnuplot index a145100..68743c4 100644 --- a/tools/performance_test/performance_test.gnuplot +++ b/tools/performance_test/performance_test.gnuplot @@ -1,5 +1,5 @@ set style line 1 lc rgb '#0060ad' lt 1 lw 2 pt 7 ps 1.5 -set terminal png size 400,300 enhanced font "Helvetica,10" +set terminal png size 800,600 enhanced font "Helvetica,10" set xlabel "time" set output 'cpu_data.png' set ylabel "CPU usage in %" diff --git a/tools/performance_test/performance_test.sh b/tools/performance_test/performance_test.sh new file mode 100755 index 0000000..eb6d45d --- /dev/null +++ b/tools/performance_test/performance_test.sh @@ -0,0 +1,129 @@ +#!/bin/bash +# USAGE: ./performance_test +# This script needs JACK to be started or just starts it itself if it isn't. + +test_dir=$(dirname $0) +cd $test_dir + +dg_path="../../drumgizmo" +sample_interval=.5 +cpu_plot_file="cpu_plot" +ram_plot_file="ram_plot" +cpu_data_file="cpu_data.dat" +ram_data_file="ram_data.dat" +dg_log_file="drumgizmo.log" + +# check for right number of parameters +if [[ $# != 3 ]] +then + echo "ERROR: You didn't supply the right number of parameters." + echo "USAGE: ./performance_test " + echo "Exiting..." + exit +fi + +kit="$1" +midimap="$2" +midifile="$3" + +# function to check for dependencies +function check_for_deps +{ + for dep in "$@" + do + if ! command -v $dep >/dev/null 2>&1 + then + echo "ERROR: Cannot find ${dep}. Maybe it isn't installed?" + echo "Exiting..." + exit + fi + done +} + +# check for drumgizmo +if ! [ -e $dg_path/drumgizmo ] +then + echo "ERROR: The drumgizmo binary doesn't exist. Maybe you forgot to compile?" + echo "Exiting..." + exit +fi + +# check for dependencies +check_for_deps gnuplot top awk + +# check for the existence of the passed files +if ! [ -e "$1" ] || ! [ -e "$2" ] || ! [ -e "$3" ] +then + echo "ERROR: One of the files (kit/midimap/midfile) doesn't exist." + echo "Exiting..." + exit +fi + +echo "============================" +echo "Starting the performace test" +echo "============================" +echo + +# initial data values +cpu_data="" +ram_data="" +avg_cpu_usage="" +time_elapsed=0 + +# log ram and cpu usage of process +function logData +{ + pid=$1 + + top_output="$(top -b -n 1 -p $pid | grep "^[ ]*$pid")" + top_arr=($top_output) + + cpu_usage="${top_arr[6]}" + ram_usage="${top_arr[7]}" + + cpu_data="${cpu_data}${time_elapsed} ${cpu_usage}\n" + ram_data="${ram_data}${time_elapsed} ${ram_usage}\n" + + 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 + if [ avg_cpu_usage_candidate != "" ]; then avg_cpu_usage=$avg_cpu_usage_candidate; fi + + # hack to allow for float addition in the bash + time_elapsed="$(awk "BEGIN {print $time_elapsed+$sample_interval; exit}")" +} + +# gnuplot ram and cpu usage over time +function plotData +{ + echo -e "$cpu_data" > $cpu_data_file + echo -e "$ram_data" > $ram_data_file + gnuplot performance_test.gnuplot > /dev/null 2>&1 +} + +# start dg +echo "The terminal output of drumgizmo is routed to ${dg_log_file}" +$dg_path/./drumgizmo -i midifile -I file="$midifile",midimap="$midimap" -o jackaudio "$kit" > $dg_log_file 2>&1 & +pid=$! + +# collect data while dg is running +echo "Collecting the data now. That might take a while..." +while ps -p $pid > /dev/null +do + logData $pid + sleep $sample_interval +done + +# plot data +plotData + +echo +echo "-------------------------------------------------------------------" +echo "The average CPU usage was: ${avg_cpu_usage}%" +echo "See the data files $cpu_data_file and $ram_data_file for details." +echo "They are nicely plotted in cpu_data.png and ram_data.png." +echo "-------------------------------------------------------------------" +echo + +echo "============================" +echo "Finished the performace test" +echo "============================" diff --git a/tools/valgrind_test/valgrind_test b/tools/valgrind_test/valgrind_test deleted file mode 100755 index b06342e..0000000 --- a/tools/valgrind_test/valgrind_test +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -test_dir=$(dirname $0) -cd $test_dir - -dg_path="../../drumgizmo" - -memcheck_log_file="valgrind_memcheck.log" -helgrind_log_file="valgrind_helgrind.log" -dg_log_file="drumgizmo.log" -memcheck_options="--tool=memcheck --log-file=$memcheck_log_file --leak-check=full --show-leak-kinds=all --track-origins=yes" -helgrind_options="--tool=helgrind --log-file=$helgrind_log_file" -midi_file="../../test/midi/file1.mid" -wav_file_prefix="valgrind_test" -midimap="../../test/kit/midimap.xml" -drumkit="../../test/kit/kit1.xml" - -# check for drumgizmo -if ! [ -e $dg_path/drumgizmo ] -then - echo "ERROR: The drumgizmo binary doesn't exist. Maybe you forgot to compile?" - exit -fi - -# check for valgrind -if ! command -v valgrind >/dev/null 2>&1 -then - echo "ERROR: Cannot find valgrind. Maybe it isn't installed?" - exit -fi - -# print nice header -echo "===========================================" -echo "Starting the valgrind test" -echo -echo "Memcheck output file: $memcheck_log_file" -echo "Helgrind output file: $helgrind_log_file" -echo "===========================================" -echo -echo "----------------" -echo "Running memcheck" -echo "----------------" -echo - -# run memcheck and print summary -valgrind $memcheck_options $dg_path/./drumgizmo -i midifile -I file=$midi_file,midimap=$midimap -o wavfile -O file=$wav_file_prefix $drumkit > /dev/null -sed -n '/LEAK SUMMARY:/,$p' $memcheck_log_file -echo -echo "=> For details see: $memcheck_log_file" - -echo -echo "----------------" -echo "Running helgrind" -echo "----------------" -echo - -# run helgrind and print summary -valgrind $helgrind_options $dg_path/./drumgizmo -i midifile -I file=$midi_file,midimap=$midimap -o wavfile -O file=$wav_file_prefix $drumkit > $dg_log_file -sed -n '/ERROR SUMMARY:/,$p' $helgrind_log_file -echo -echo "=> For details see: $helgrind_log_file" - -echo - -# delete created wav files -rm *.wav diff --git a/tools/valgrind_test/valgrind_test.sh b/tools/valgrind_test/valgrind_test.sh new file mode 100755 index 0000000..b06342e --- /dev/null +++ b/tools/valgrind_test/valgrind_test.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +test_dir=$(dirname $0) +cd $test_dir + +dg_path="../../drumgizmo" + +memcheck_log_file="valgrind_memcheck.log" +helgrind_log_file="valgrind_helgrind.log" +dg_log_file="drumgizmo.log" +memcheck_options="--tool=memcheck --log-file=$memcheck_log_file --leak-check=full --show-leak-kinds=all --track-origins=yes" +helgrind_options="--tool=helgrind --log-file=$helgrind_log_file" +midi_file="../../test/midi/file1.mid" +wav_file_prefix="valgrind_test" +midimap="../../test/kit/midimap.xml" +drumkit="../../test/kit/kit1.xml" + +# check for drumgizmo +if ! [ -e $dg_path/drumgizmo ] +then + echo "ERROR: The drumgizmo binary doesn't exist. Maybe you forgot to compile?" + exit +fi + +# check for valgrind +if ! command -v valgrind >/dev/null 2>&1 +then + echo "ERROR: Cannot find valgrind. Maybe it isn't installed?" + exit +fi + +# print nice header +echo "===========================================" +echo "Starting the valgrind test" +echo +echo "Memcheck output file: $memcheck_log_file" +echo "Helgrind output file: $helgrind_log_file" +echo "===========================================" +echo +echo "----------------" +echo "Running memcheck" +echo "----------------" +echo + +# run memcheck and print summary +valgrind $memcheck_options $dg_path/./drumgizmo -i midifile -I file=$midi_file,midimap=$midimap -o wavfile -O file=$wav_file_prefix $drumkit > /dev/null +sed -n '/LEAK SUMMARY:/,$p' $memcheck_log_file +echo +echo "=> For details see: $memcheck_log_file" + +echo +echo "----------------" +echo "Running helgrind" +echo "----------------" +echo + +# run helgrind and print summary +valgrind $helgrind_options $dg_path/./drumgizmo -i midifile -I file=$midi_file,midimap=$midimap -o wavfile -O file=$wav_file_prefix $drumkit > $dg_log_file +sed -n '/ERROR SUMMARY:/,$p' $helgrind_log_file +echo +echo "=> For details see: $helgrind_log_file" + +echo + +# delete created wav files +rm *.wav -- cgit v1.2.3