benchmarkRT update: added -a option to iteratively and easily speed-test all tools in RT

This commit is contained in:
DrSlony 2013-03-24 01:04:00 +00:00
parent 56ec1070c3
commit 26fe2cd256

View File

@ -5,6 +5,7 @@
# v2 2013-02-15
# v3 2013-03-04
# v4 2013-03-07
# v5 2013-03-23
# www.rawtherapee.com
revision="tip"
@ -32,6 +33,7 @@ Usage:
./benchmarkRT [OPTIONS]
Options:
-a - Run a benchmark for all the tools available in RT, one at a time.
-e - Specify the whole path to (but excluding) the "rawtherapee"
executable.
e.g. "-e $HOME/rt_${branch}_${buildType}"
@ -89,8 +91,10 @@ download () {
fi
}
while getopts "e:h?i:s:" opt; do
while getopts "ae:h?i:s:" opt; do
case "$opt" in
a) testAllTools=1
;;
e) customExeDir="${OPTARG%/}"
;;
h|\?)
@ -108,8 +112,6 @@ shift $((OPTIND-1))
[ "$1" = "--" ] && shift
# tmpDir = /tmp/rawtherapee-benchmark
inFileName="`basename "${inFile}"`"
if [[ ! -e "${tmpDir}" ]]; then
if [[ ! -w /tmp ]]; then
@ -153,6 +155,7 @@ if [[ ! -x "${rtExeDir}/${rtExe}" ]]; then
exit 0
fi
if [[ $testAllTools -ne 1 ]]; then
if [[ -n "${sidecarCustom}" ]]; then # if sidecarCustom was specified
if [[ ${sidecarCustom} = http* ]]; then # and if sidecarCustom starts with an http
if [[ ! -e "${tmpDir}/$/{sidecarCustom##*/}" ]]; then # and if sidecarCustom hasn't been previously downloaded, then download it
@ -187,9 +190,22 @@ else # if sidecarCustom was not specified, find the default ones
fi
sidecarFiles=("${sidecarDefault[@]}")
fi
else
unset sidecarFiles avgTable
sidecarDir="${tmpDir}/"
tools=("Auto Exposure;Exposure;Auto=true" "Sharpening - Unsharp Mask;Sharpening;Enabled=true;Method=usm" "Sharpening - RL Deconvolution;Sharpening;Enabled=true;Method=rld" "Vibrance;Vibrance;Enabled=true" "Edges;SharpenEdge;Enabled=true" "Microcontrast;SharpenMicro;Enabled=true" "CIECAM02;Color appearance;Enabled=true" "Impulse Noise Reduction;Impulse Denoising;Enabled=true" "Defringe;Defringing;Enabled=true" "Noise Reduction;Directional Pyramid Denoising;Enabled=true" "Tone Mapping;EPD;Enabled=true" "Shadows/Highlights;Shadows & Highlights;Enabled=true" "Contrast by Detail Levels;Directional Pyramid Equalizer;Enabled=true" "Raw Chromatic Aberration;RAW;CA=true")
for i in "${!tools[@]}"; do
IFS=";" read toolNameHuman tool key1 key2 key3 <<< "${tools[$i]}"
i=`printf "%02d\n" "$i"`
printf "%s\n" "[${tool}]" "$key1" "$key2" "$key3" > "${sidecarDir}/${i} - ${tool}.pp3"
sidecarFiles+=("${i} - ${tool}.pp3;${toolNameHuman}")
done
fi
printf "%s\n" "" "--------------------------------------------------------------------------------" "" "Benchmark of RawTherapee"
printf "%s\n" "`uname -srvmpio`" ""
hash cpufreq-info 2>/dev/null && cpufreq-info -mo
printf "%s\n" ""
if [[ ! -f "${rtExeDir}/AboutThisBuild.txt" ]]; then
printf "%s\n" "[Could not find ${rtExeDir}/AboutThisBuild.txt]" ""
@ -199,27 +215,55 @@ fi
printf "%s\n" "Photo: ${tmpDir}/${inFileName}"
for sidecar in "${sidecarFiles[@]}"; do
printf "%s\n" "Sidecar[s]: ${sidecarDir}${sidecar}"
if [[ $testAllTools -eq 1 ]]; then
IFS=";" read sidecar toolNameHuman <<< "${sidecar}"
fi
printf "%s\n" "Sidecar: ${sidecarDir}${sidecar}"
done
echo
unset sidecar
unset total
for sidecar in "${sidecarFiles[@]}"; do
declare -A avgTable
unset benchmark total sidecar sorted
for s in "${!sidecarFiles[@]}"; do
IFS=";" read sidecar toolNameHuman <<< "${sidecarFiles[s]}"
unset benchmark
for (( i=1; i<=${runs}; i++ )); do
# printf "%s\n" "rtExe is $rtExe" "tmpDir is $tmpDir" "sidecarDir is $sidecarDir" "sidecar is $sidecar" "outFileFormat is $outFileFormat" "tmpDir is $tmpDir" "inFileName is $inFileName"
runTime="$( { time "${rtExeDir}/${rtExe}" -o "$tmpDir" -p "${sidecarDir}${sidecar}" "$outFileFormat" -Y -c "${tmpDir}/${inFileName}"; } 2>&1 | grep ^real; )"
runTime="$( { time "${rtExeDir}/${rtExe}" -o /dev/null -p "${sidecarDir}${sidecar}" "$outFileFormat" -Y -c "${tmpDir}/${inFileName}"; } 2>&1 | grep ^real; )"
# runTime=real 0m4.751s
runTime=${runTime#*[[:blank:]]}
# runTime=0m4.751s
minOnly=${runTime%m*}
secOnly=${runTime#*m}; secOnly=${secOnly%s*}
t="$( printf "%s\n" "scale=3; $secOnly+$minOnly*60" | bc )"
# t=4.751
## t="$(( $RANDOM %20 )).$(( $RANDOM %999 ))"
# benchmark stores time array of each run, gets reset after each PP3
benchmark+=("$t")
# total stores time array of each run, doesnt get reset, adds up total afterwards
total+=("$t")
printf "%b\n" "Benchmark ${sidecar##*/} ${i}:\t${benchmark[$i - 1]}"
i=`printf "%02d\n" "$i"`
if [[ $testAllTools -eq 1 ]]; then
printf "%*b" "-50" "Benchmark ${i} \"${toolNameHuman}\"" "7" "${benchmark[$i - 1]}" "" "\n" | sed 's/ /../g'
else
printf "%*b" "-50" "Benchmark ${i} \"${sidecar##*/}\"" "7" "${benchmark[$i - 1]}" "" "\n" | sed 's/ /../g'
fi
done
avg=$( { printf "%s" "scale=3; ("; IFS="+"; printf "%s" "${benchmark[*]}"; printf "%s\n" ") / ${#benchmark[@]}"; } | bc );
printf "%b\n" "Benchmark ${sidecar##*/} average:\t${avg}" ""
if [[ $testAllTools -eq 1 ]]; then
printf "%*b" "-50" "Benchmark \"${toolNameHuman}\" average" "7" "${avg}" "" "\n\n" | sed 's/ /../g'
avgTable+=(["${toolNameHuman}"]="$avg")
else
printf "%*b" "-50" "Benchmark \"${sidecar##*/}\" average" "7" "${avg}" "" "\n\n" | sed 's/ /../g'
avgTable+=(["${sidecar}"]="$avg")
fi
done
printf "Benchmark total:\t`IFS=+; bc -l <<< "${total[*]}"`\n"
printf "%*b" "-50" "Benchmark total" "7" "`IFS=+; bc -l <<< "${total[*]}"`" "" "\n\n" | sed 's/ /../g'
# Associative arrays don't return in alphanumerical order, must be sorted manually
IFS=$'\n' sorted=($(sort <<<"${!avgTable[*]}"));
printf "%s\n" "Average times for each tool:"
for x in "${sorted[@]}"; do
printf "%*b" "-50" "${x}" "7" "${avgTable[$x]}" "" "\n" | sed 's/ /../g'
done