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 # v2 2013-02-15
# v3 2013-03-04 # v3 2013-03-04
# v4 2013-03-07 # v4 2013-03-07
# v5 2013-03-23
# www.rawtherapee.com # www.rawtherapee.com
revision="tip" revision="tip"
@ -32,6 +33,7 @@ Usage:
./benchmarkRT [OPTIONS] ./benchmarkRT [OPTIONS]
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" -e - Specify the whole path to (but excluding) the "rawtherapee"
executable. executable.
e.g. "-e $HOME/rt_${branch}_${buildType}" e.g. "-e $HOME/rt_${branch}_${buildType}"
@ -89,8 +91,10 @@ download () {
fi fi
} }
while getopts "e:h?i:s:" opt; do while getopts "ae:h?i:s:" opt; do
case "$opt" in case "$opt" in
a) testAllTools=1
;;
e) customExeDir="${OPTARG%/}" e) customExeDir="${OPTARG%/}"
;; ;;
h|\?) h|\?)
@ -108,8 +112,6 @@ shift $((OPTIND-1))
[ "$1" = "--" ] && shift [ "$1" = "--" ] && shift
# tmpDir = /tmp/rawtherapee-benchmark
inFileName="`basename "${inFile}"`" inFileName="`basename "${inFile}"`"
if [[ ! -e "${tmpDir}" ]]; then if [[ ! -e "${tmpDir}" ]]; then
if [[ ! -w /tmp ]]; then if [[ ! -w /tmp ]]; then
@ -153,43 +155,57 @@ if [[ ! -x "${rtExeDir}/${rtExe}" ]]; then
exit 0 exit 0
fi fi
if [[ -n "${sidecarCustom}" ]]; then # if sidecarCustom was specified if [[ $testAllTools -ne 1 ]]; then
if [[ ${sidecarCustom} = http* ]]; then # and if sidecarCustom starts with an http if [[ -n "${sidecarCustom}" ]]; then # if sidecarCustom was specified
if [[ ! -e "${tmpDir}/$/{sidecarCustom##*/}" ]]; then # and if sidecarCustom hasn't been previously downloaded, then download it if [[ ${sidecarCustom} = http* ]]; then # and if sidecarCustom starts with an http
printf "${sidecarCustom} not found in ${tmpDir}, downloading it.\n" if [[ ! -e "${tmpDir}/$/{sidecarCustom##*/}" ]]; then # and if sidecarCustom hasn't been previously downloaded, then download it
download "$sidecarCustom" printf "${sidecarCustom} not found in ${tmpDir}, downloading it.\n"
download "$sidecarCustom"
fi
else # else if sidecarCustom does not start with an http
for sidecarFile in "${sidecarCustom[@]}"; do
[[ ! -e "${sidecarFile}" ]] && { # then check if it exists
printf "You specified \"-s ${sidecarFile}\" but it does not exist. Make sure you wrote a full, absolute path, e.g.:" " -s /tmp/kittens_denoise.raw.pp3"
exit 1
}
done
unset sidecarFiles
sidecarDir=""
sidecarFiles=("${sidecarCustom[@]}")
fi fi
else # else if sidecarCustom does not start with an http else # if sidecarCustom was not specified, find the default ones
for sidecarFile in "${sidecarCustom[@]}"; do for sidecar in "${sidecarDefault[@]}"; do
[[ ! -e "${sidecarFile}" ]] && { # then check if it exists if [[ -f "${rtExeDir}/profiles/${sidecar}" ]]; then
printf "You specified \"-s ${sidecarFile}\" but it does not exist. Make sure you wrote a full, absolute path, e.g.:" " -s /tmp/kittens_denoise.raw.pp3" sidecarDir="${rtExeDir}/profiles/"
exit 1 elif [[ -f "${tmpDir}/${sidecar}" ]]; then
} sidecarDir="${tmpDir}/"
else
printf "%s\n" "" "Could not find \"${sidecar}\" in \"${rtExeDir}/profiles/\" where it was expected to be." "Downloading the latest \"${sidecar}\" from the repository." ""
download "https://rawtherapee.googlecode.com/hg/rtdata/profiles/${sidecar}"
sidecarDir="${tmpDir}/"
fi
done done
unset sidecarFiles if [[ "${sidecarDir}" = "${tmpDir}/" ]]; then
sidecarDir="" printf "%s\n" "Beware that the downloaded processing profiles might not be entirely compatible with the RawTherapee version you're testing. For authentic and consistent results, make sure that the PP3 files match this RawTherapee version. You can use the -p flag to point benchmarkRT to the correct PP3 file(s)." | fold -s
sidecarFiles=("${sidecarCustom[@]}")
fi
else # if sidecarCustom was not specified, find the default ones
for sidecar in "${sidecarDefault[@]}"; do
if [[ -f "${rtExeDir}/profiles/${sidecar}" ]]; then
sidecarDir="${rtExeDir}/profiles/"
elif [[ -f "${tmpDir}/${sidecar}" ]]; then
sidecarDir="${tmpDir}/"
else
printf "%s\n" "" "Could not find \"${sidecar}\" in \"${rtExeDir}/profiles/\" where it was expected to be." "Downloading the latest \"${sidecar}\" from the repository." ""
download "https://rawtherapee.googlecode.com/hg/rtdata/profiles/${sidecar}"
sidecarDir="${tmpDir}/"
fi fi
done sidecarFiles=("${sidecarDefault[@]}")
if [[ "${sidecarDir}" = "${tmpDir}/" ]]; then
printf "%s\n" "Beware that the downloaded processing profiles might not be entirely compatible with the RawTherapee version you're testing. For authentic and consistent results, make sure that the PP3 files match this RawTherapee version. You can use the -p flag to point benchmarkRT to the correct PP3 file(s)." | fold -s
fi fi
sidecarFiles=("${sidecarDefault[@]}") 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 fi
printf "%s\n" "" "--------------------------------------------------------------------------------" "" "Benchmark of RawTherapee" printf "%s\n" "" "--------------------------------------------------------------------------------" "" "Benchmark of RawTherapee"
printf "%s\n" "`uname -srvmpio`" "" printf "%s\n" "`uname -srvmpio`" ""
hash cpufreq-info 2>/dev/null && cpufreq-info -mo
printf "%s\n" ""
if [[ ! -f "${rtExeDir}/AboutThisBuild.txt" ]]; then if [[ ! -f "${rtExeDir}/AboutThisBuild.txt" ]]; then
printf "%s\n" "[Could not find ${rtExeDir}/AboutThisBuild.txt]" "" printf "%s\n" "[Could not find ${rtExeDir}/AboutThisBuild.txt]" ""
@ -197,29 +213,57 @@ else
cat "${rtExeDir}/AboutThisBuild.txt" cat "${rtExeDir}/AboutThisBuild.txt"
fi fi
printf "%s\n" "Photo: ${tmpDir}/${inFileName}" printf "%s\n" "Photo: ${tmpDir}/${inFileName}"
for sidecar in "${sidecarFiles[@]}"; do 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 done
echo echo
unset sidecar declare -A avgTable
unset total unset benchmark total sidecar sorted
for sidecar in "${sidecarFiles[@]}"; do for s in "${!sidecarFiles[@]}"; do
IFS=";" read sidecar toolNameHuman <<< "${sidecarFiles[s]}"
unset benchmark unset benchmark
for (( i=1; i<=${runs}; i++ )); do 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 /dev/null -p "${sidecarDir}${sidecar}" "$outFileFormat" -Y -c "${tmpDir}/${inFileName}"; } 2>&1 | grep ^real; )"
runTime="$( { time "${rtExeDir}/${rtExe}" -o "$tmpDir" -p "${sidecarDir}${sidecar}" "$outFileFormat" -Y -c "${tmpDir}/${inFileName}"; } 2>&1 | grep ^real; )" # runTime=real 0m4.751s
runTime=${runTime#*[[:blank:]]} runTime=${runTime#*[[:blank:]]}
# runTime=0m4.751s
minOnly=${runTime%m*} minOnly=${runTime%m*}
secOnly=${runTime#*m}; secOnly=${secOnly%s*} secOnly=${runTime#*m}; secOnly=${secOnly%s*}
t="$( printf "%s\n" "scale=3; $secOnly+$minOnly*60" | bc )" 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") benchmark+=("$t")
# total stores time array of each run, doesnt get reset, adds up total afterwards
total+=("$t") 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 done
avg=$( { printf "%s" "scale=3; ("; IFS="+"; printf "%s" "${benchmark[*]}"; printf "%s\n" ") / ${#benchmark[@]}"; } | bc ); 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 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