Revision of benchmarkRT

This commit is contained in:
DrSlony
2013-03-08 02:03:50 +00:00
parent 8b5d8e637d
commit 9ff57c0135

View File

@@ -4,6 +4,7 @@
# v1 2012-02-10 # v1 2012-02-10
# v2 2013-02-15 # v2 2013-02-15
# v3 2013-03-04 # v3 2013-03-04
# v4 2013-03-07
# www.rawtherapee.com # www.rawtherapee.com
revision="tip" revision="tip"
@@ -61,13 +62,33 @@ Examples:
Further help: Further help:
If you need further help, discover bugs or want to request new functionality If you need further help, discover bugs or want to request new functionality
in this script, then tell us in the forum or on IRC: rn this script, then tell us in the forum or on IRC:
http://rawtherapee.com/forum/ http://rawtherapee.com/forum/
http://webchat.freenode.net/?randomnick=1&channels=rawtherapee&prompt=1 http://webchat.freenode.net/?randomnick=1&channels=rawtherapee&prompt=1
END END
} }
download () {
local retries=10
while [[ $retries -ne 0 ]]; do
wget --progress=dot:binary --continue --trust-server-names --tries=5 --timestamping "$1" 2>&1 | sed "s/^/\t/"
return=${PIPESTATUS[0]}
((retries--))
if [[ $return -eq 0 ]]; then # I don't trust wget to only exit with 0 if it downloaded the file succesfully, so I check.
if [[ -f "`basename "$1"`" ]]; then
break
fi
fi
printf "%s\n\n" "Failed to download \"$1\"" "Retrying: "
sleep 1s
done
if [[ $retries -eq 0 ]]; then
printf "%s\n" "Tried to download \"$1\" 10 times but failed. Exiting."
exit 1
fi
}
while getopts "e:h?i:s:" opt; do while getopts "e:h?i:s:" opt; do
case "$opt" in case "$opt" in
e) customExeDir="${OPTARG%/}" e) customExeDir="${OPTARG%/}"
@@ -102,13 +123,13 @@ trap 'rm -rv "${tmpDir}"; exit 1' HUP INT QUIT ABRT TERM
cd "$tmpDir" cd "$tmpDir"
if [[ ${inFile} = http* ]]; then # if inFile is a url if [[ ${inFile} = http* ]]; then # if inFile is a url and if we haven't downloaded it already, then download it
[[ ! -e "${tmpDir}/${inFileName}" ]] && { # and if we haven't downloaded it already [[ ! -e "${tmpDir}/${inFileName}" ]] && {
printf "${inFileName} not found in ${tmpDir}, downloading it.\n" printf "%s\n\n" "${inFileName} not found in ${tmpDir}, downloading it."
[[ ! -w /tmp ]] && { printf "Error: /tmp is not writable.\n"; exit 1; } [[ ! -w /tmp ]] && { printf "Error: /tmp is not writable.\n"; exit 1; }
[[ ! -e "$tmpDir" ]] && mkdir "$tmpDir" [[ ! -e "$tmpDir" ]] && mkdir "$tmpDir"
cd "$tmpDir" cd "$tmpDir"
wget -c --trust-server-names "$inFile" # then download it. download "$inFile"
echo echo
} }
else # otherwise if inFile is not a url, check if it exists else # otherwise if inFile is not a url, check if it exists
@@ -119,11 +140,24 @@ else # otherwise if inFile is not a url, check if it exists
cp "${inFile}" "${tmpDir}/${inFileName}" cp "${inFile}" "${tmpDir}/${inFileName}"
fi fi
rtExeDirs=("${customExeDir}" "$HOME/rt_${branch}_${buildType}" "$HOME/rt_${branch}_${buildType}_patched" "$HOME/rawtherapee/")
for rtExeDir in "${rtExeDirs[@]}"; do
if [[ -x "${rtExeDir}/${rtExe}" ]]; then
printf "%s\n" "Using RawTherapee executable:" "${rtExeDir}/${rtExe}"
break
fi
done
if [[ ! -x "${rtExeDir}/${rtExe}" ]]; then
printf "%s\n" "Could not find the RawTherapee executable:" "${rtExeDir}/${rtExe}" "Re-run this script using the -e flag."
exit 0
fi
if [[ -n "${sidecarCustom}" ]]; then # if sidecarCustom was specified if [[ -n "${sidecarCustom}" ]]; then # if sidecarCustom was specified
if [[ ${sidecarCustom} = http* ]]; then # and if sidecarCustom starts with an http 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 if [[ ! -e "${tmpDir}/$/{sidecarCustom##*/}" ]]; then # and if sidecarCustom hasn't been previously downloaded, then download it
printf "${sidecarCustom} not found in ${tmpDir}, downloading it.\n" printf "${sidecarCustom} not found in ${tmpDir}, downloading it.\n"
wget -c --trust-server-names "$sidecarCustom" download "$sidecarCustom"
fi fi
else # else if sidecarCustom does not start with an http else # else if sidecarCustom does not start with an http
for sidecarFile in "${sidecarCustom[@]}"; do for sidecarFile in "${sidecarCustom[@]}"; do
@@ -136,57 +170,27 @@ if [[ -n "${sidecarCustom}" ]]; then # if sidecarCustom was specified
sidecarDir="" sidecarDir=""
sidecarFiles=("${sidecarCustom[@]}") sidecarFiles=("${sidecarCustom[@]}")
fi fi
else # if sidecarCustom was not specified, use the ones in sidecarDefault else # if sidecarCustom was not specified, find the default ones
sidecarDirs=("$HOME/rt_${branch}_${buildType}_patched/profiles/" "${tmpDir}/" "$HOME/.config/RawTherapee4/profiles/")
for dir in "${sidecarDirs[@]}"; do
for sidecar in "${sidecarDefault[@]}"; do for sidecar in "${sidecarDefault[@]}"; do
# echo "Checking for ${sidecar} in ${dir}" if [[ -f "${rtExeDir}/profiles/${sidecar}" ]]; then
if [[ -f "${dir}${sidecar}" ]]; then sidecarDir="${rtExeDir}/profiles/"
sidecarDir="$dir" elif [[ -f "${tmpDir}/${sidecar}" ]]; then
found="true" sidecarDir="${tmpDir}/"
# echo "Found sidecar ${sidecar} in ${sidecarDir[@]}" 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 done
[[ -n $found ]] && break if [[ "${sidecarDir}" = "${tmpDir}/" ]]; then
done 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
# if the loop above did not find a Neutral.pp3 anywhere, then we download one to $tmpDir fi
[[ -z $found ]] && {
wget -c --trust-server-names "http://code.google.com/p/rawtherapee/source/browse/rtdata/profiles/Neutral.pp3" "http://code.google.com/p/rawtherapee/source/browse/rtdata/profiles/Default.pp3"
sidecarDir="${tmpDir}/"
}
sidecarFiles=("${sidecarDefault[@]}") sidecarFiles=("${sidecarDefault[@]}")
fi fi
rtExeDirs=("${customExeDir}" "$HOME/rt_${branch}_${buildType}" "$HOME/rt_${branch}_${buildType}_patched" "$HOME/rawtherapee/") printf "%s\n" "" "--------------------------------------------------------------------------------" "" "Benchmark of RawTherapee"
for rtExeDir in "${rtExeDirs[@]}"; do
# test below prevents looking for RT in empty rtExeDir variables, so the printf doesn't report "Checking for RawTherapee executable in " with no dir.
[[ $rtExeDir ]] && {
if [[ -x "${rtExeDir}/${rtExe}" ]]; then
printf "%s\n" "Using RawTherapee executable: ${rtExeDir}/${rtExe}"
break
else
printf "%s\n" "Checking for RawTherapee executable in $rtExeDir"
fi
}
done
if [[ ! -x "${rtExeDir}/${rtExe}" ]]; then
printf "%s\n" "Could not find the RawTherapee executable. Re-run this script using the -e flag." | fold -s
exit 0
fi
printf "%s\n" "--------------------------------------------------------------------------" "" "Benchmark of RawTherapee"
printf "%s\n" "`uname -srvmpio`" "" printf "%s\n" "`uname -srvmpio`" ""
#rtATBdirs=("${tmpDir}/rt_${branch}_${buildType}" "$HOME/rt_${branch}_${buildType}" "${repo}/rt_${branch}_${buildType}" "${repo}/release" "$HOME/rawtherapee")
#for rtATBdir in "${rtATBdirs[@]}"; do
# if [[ -f "${rtATBdir}/AboutThisBuild.txt" ]]; then
# printf "%s\n" "${rtATBdir}/AboutThisBuild.txt"
# cat "${rtATBdir}/AboutThisBuild.txt"
# break
# fi
#done
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]" ""
else else
@@ -200,15 +204,22 @@ done
echo echo
unset sidecar unset sidecar
unset total
for sidecar in "${sidecarFiles[@]}"; do for sidecar in "${sidecarFiles[@]}"; do
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" # printf "%s\n" "rtExe is $rtExe" "tmpDir is $tmpDir" "sidecarDir is $sidecarDir" "sidecar is $sidecar" "outFileFormat is $outFileFormat" "tmpDir is $tmpDir" "inFileName is $inFileName"
benchmark+=("`\time -f %e "${rtExeDir}/${rtExe}" -o "$tmpDir" -p "${sidecarDir}${sidecar}" "$outFileFormat" -Y -c "${tmpDir}/${inFileName}" 2>&1 >/dev/null`") runTime="$( { time "${rtExeDir}/${rtExe}" -o "$tmpDir" -p "${sidecarDir}${sidecar}" "$outFileFormat" -Y -c "${tmpDir}/${inFileName}"; } 2>&1 | grep ^real; )"
printf "%b\n" "Benchmark ${sidecar##*/} ${i}: ${benchmark[$i - 1]}" runTime=${runTime#*[[:blank:]]}
minOnly=${runTime%m*}
secOnly=${runTime#*m}; secOnly=${secOnly%s*}
t="$( printf "%s\n" "scale=3; $secOnly+$minOnly*60" | bc )"
benchmark+=("$t")
total+=("$t")
printf "%b\n" "Benchmark ${sidecar##*/} ${i}:\t${benchmark[$i - 1]}"
done done
avg=$( { printf "scale=2; ("; IFS="+"; printf %s "${benchmark[*]}"; echo ") / ${#benchmark[@]}"; } | bc) avg=$( { printf "%s" "scale=3; ("; IFS="+"; printf "%s" "${benchmark[*]}"; printf "%s\n" ") / ${#benchmark[@]}"; } | bc );
printf "%b\n" "Benchmark ${sidecar##*/} average:\t${avg}" "" printf "%b\n" "Benchmark ${sidecar##*/} average:\t${avg}" ""
done done
printf "Total runtime:\t`IFS=+; bc -l <<< "${benchmark[*]}"`\n" printf "Benchmark total:\t`IFS=+; bc -l <<< "${total[*]}"`\n"