Skip to content

Commit

Permalink
Working on issue #67 (performance profiling infrastructure): Added sc…
Browse files Browse the repository at this point in the history
…ript to parse profiling configurations and extended them with measurement result configuration section.
  • Loading branch information
christoff-buerger committed Oct 7, 2016
1 parent 128f93e commit 52e27f6
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 35 deletions.
2 changes: 2 additions & 0 deletions profiling/atomic-petrinets/profiling-configuration
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
#Influenced|Number of transitions influenced including the one fired
#L-Places|Number of local places per transition
#L-Tokens|Number of tokens in local places
>
Time|Execution time in ms
27 changes: 13 additions & 14 deletions profiling/make-measurements.bash
Original file line number Diff line number Diff line change
Expand Up @@ -113,24 +113,23 @@ echo "set -o pipefail" >> "$rerun_script"
echo "cd \"$call_dir\"" >> "$rerun_script"
echo "\"$script_dir/make-measurements.bash\" -c \"$profiling_configuration\" -s /dev/null -- << EOF" >> "$rerun_script"

############################################################################################################# Read configuration:
. "$script_dir/parse-profiling-configuration.bash" # Sourced script sets configuration!

################################################################################################################ Read parameters:
declare -a parameter_names
declare -a parameter_values
declare -a parameter_iterations
declare -a parameter_adjustments

echo "************************************************** configuration **************************************************"
exec 3< "$profiling_configuration"
while read -r line <&3
#exec 3< "$profiling_configuration"
#while read -r line <&3
for (( i = 0; i < number_of_parameters; i++ ))
do
IFS='|' read -ra config_line <<< "$line"

parameter_names+=( "${config_line[0]}" )

read -r -p "${config_line[1]} [${config_line[0]}]: " choice
read -r -p "${parameter_descriptions[$i]} [${parameter_names[$i]}]: " choice
if [ ! -t 0 ]
then
echo "${config_line[1]} [${config_line[0]}]: $choice"
echo "${parameter_descriptions[$i]} [${parameter_names[$i]}]: $choice"
fi
echo "$choice" >> "$rerun_script"
parameter_values+=( "$choice" )
Expand Down Expand Up @@ -158,11 +157,11 @@ do
''|*[0-9]*)
if [ "$choice" -lt 1 ]
then
echo " !!! ERROR: No valid choice entered !!!" >&2
echo " !!! ERROR: Invalid choice !!!" >&2
exit 2
fi;;
*)
echo " !!! ERROR: No valid choice entered !!!" >&2
echo " !!! ERROR: Invalid choice !!!" >&2
exit 2;;
esac
parameter_iterations+=( "$choice" )
Expand All @@ -176,19 +175,19 @@ do
''|*[0-9]*)
;;
*)
echo " !!! ERROR: No valid choice entered !!!" >&2
echo " !!! ERROR: Invalid choice !!!" >&2
exit 2;;
esac
parameter_adjustments+=( "$choice" );;
[n]*)
parameter_iterations+=( 1 )
parameter_adjustments+=( 0 );;
*)
echo " !!! ERROR: No valid choice entered !!!" >&2
echo " !!! ERROR: Invalid choice !!!" >&2
exit 2;;
esac
done
exec 3<&-
#exec 3<&-
echo "EOF" >> "$rerun_script"
valid_parameters=1

Expand Down
48 changes: 27 additions & 21 deletions profiling/make-table.bash
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ then
exit 2
fi

if [ -z ${measurements_table+x} ]
if [ -z ${measurements_table+x} ] ||
[ ! -d "`dirname "$measurements_table"`" ] ||
[ -e "$measurements_table" -a ! -f "$measurements_table" ]
then
echo " !!! ERROR: No measurements table for logging specified via -t flag !!!" >&2
exit 2
elif [ ! -d "`dirname "$measurements_table"`" ]
then
echo " !!! ERROR: Measurements table for logging specified via -t flag has invalid directory !!!" >&2
echo " !!! ERROR: Invalid or no measurements table specified via -t flag !!!" >&2
exit 2
fi

Expand All @@ -80,26 +78,29 @@ then
fi

############################################################################################################# Read configuration:
while read -r line
do
IFS='|' read -ra config_line <<< "$line"
column_names+=( "${config_line[0]}" )
done < "$profiling_configuration"
num_columns=${#column_names[@]}
. "$script_dir/parse-profiling-configuration.bash" # Sourced script sets configuration!

############################################################################################################# Print table header:
if [ ! -e "$measurements_table" ]
then
for (( i = 0; i < num_columns; i++ ))
for (( i = 0; i < number_of_parameters; i++ ))
do
printf " %-18s |" "${parameter_names[$i]}" >> "$measurements_table"
done
for (( i = 0; i < number_of_results; i++ ))
do
printf " %-18s |" "${column_names[$i]}" >> "$measurements_table"
printf "| %-18s" "${result_names[$i]}" >> "$measurements_table"
done
printf " %-18s \n" "Time in s" >> "$measurements_table"
for (( i = 0; i < num_columns; i++ ))
printf "\n" >> "$measurements_table"
for (( i = 0; i < number_of_parameters; i++ ))
do
printf "%s" "--------------------+" >> "$measurements_table"
done
echo "--------------------" >> "$measurements_table"
for (( i = 0; i < number_of_results; i++ ))
do
printf "%s" "+--------------------" >> "$measurements_table"
done
printf "\n" >> "$measurements_table"
fi

############################################################################################################ Print table content:
Expand All @@ -108,12 +109,17 @@ while true #lsof "$measurements_pipe"
do
if read -r line
then
if (( column_count < num_columns ))
if (( column_count < number_of_parameters ))
then
printf " %-18s |" "$line" >> "$measurements_table"
column_count=$(( column_count + 1 ))
else
printf " %-18s \n" "$line" >> "$measurements_table"
elif (( column_count < number_of_parameters + number_of_results ))
then
printf "| %-18s" "$line" >> "$measurements_table"
fi
column_count=$(( column_count + 1 ))
if (( column_count >= number_of_parameters + number_of_results ))
then
print "\n" >> "$measurements_table"
column_count=0
fi
else
Expand Down
63 changes: 63 additions & 0 deletions profiling/parse-profiling-configuration.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# This program and the accompanying materials are made available under the
# terms of the MIT license (X11 license) which accompanies this distribution.

# author: C. Bürger

# BEWARE: This script must be sourced. It expects one variables to be set and sets six variables:
# in) profiling_configuration: Profiling configuration file to parse
# set) parameter_names: Array of the names of parameters as defined by the parsed configuration
# set) parameter_descriptions: Array of parameters descriptions as given by the parsed configuration
# (one description for each parameter)
# set) result_names: Array of the names of measurement results as defined by the parsed configuration
# set) result_descriptions: Array of measurement result descriptions as given by the parsed configuration
# (one description for each measurement result)
# set) number_of_parameters: Number of parameters defined by the parsed configuration
# set) number_of_results: Number of measurement results defined by the parsed configuration

set -e
set -o pipefail
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [ -z ${profiling_configuration+x} ] || [ ! -f "$profiling_configuration" ]
then
echo " !!! ERROR: Non-existent or no profiling configuration to parse set !!!" >&2
exit 2
fi

parsing_mode=parameters
parameter_names=()
parameter_descriptions=()
result_names=()
result_descriptions=()
while read line
do
case $parsing_mode in
parameters)
if [ "$line" == ">" ]
then
parsing_mode=results
continue;
fi
IFS='|' read -ra config_line <<< "$line"
if [ ${#config_line[@]} -ne 2 ]
then
echo " !!! ERROR: Malformed profiling configuration (parameter syntax error) !!!" >&2
exit 2
fi
parameter_names+=( "${config_line[0]}" )
parameter_descriptions+=( "${config_line[1]}" );;
results)
IFS='|' read -ra config_line <<< "$line"
if [ ${#config_line[@]} -ne 2 ]
then
echo " !!! ERROR: Malformed profiling configuration (measurement result syntax error) !!!" >&2
exit 2
fi
result_names+=( "${config_line[0]}" )
result_descriptions+=( "${config_line[1]}" );;
esac
done < "$profiling_configuration"
number_of_parameters=${#parameter_names[@]}
number_of_results=${#result_names[@]}

0 comments on commit 52e27f6

Please sign in to comment.