Revision of benchmarkRT

This commit is contained in:
DrSlony
2013-03-04 04:49:05 +00:00
parent c32bd814f0
commit 12d88f00d3

View File

@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# Use this Bash script to test RT processing speed.
# Written by DrSlony
# 2012-02-10
# www.seeitmyway.org
# v1 2012-02-10
# v2 2013-02-15
# www.rawtherapee.com
revision="tip"
@@ -17,48 +17,32 @@ outFileFormat="-t"
tmpDir="/tmp/rawtherapee-benchmark"
runs=5
echo
howto() {
fold -s <<END
Benchmark the time it takes for a given version of RawTherapee to process a file. The designated file will be processed three times in a row, and the average time of those three runs will be calculated. Make sure you have no unnecessary background activity - no programs intensely using the CPU. Turn off all P2P, multimedia, graphics editing, games, database, server and other "heavy" software, otherwise the timings will be skewed. You can use the "top" and "ps ux" commands to see a list of running processes and their CPU usage.
Benchmark the time it takes for RawTherapee to process an image file. The designated file will be processed five times in a row, and the average time of those five runs will be calculated.
All options are optional.
Make sure you have no unnecessary background activity - no programs intensively using the CPU. Turn off all P2P, multimedia, graphics editing, games, database, server and other "heavy" software, otherwise the timings will be skewed. You can use the "top" and "ps ux" commands to see a list of running processes and their CPU usage.
Usage:
./benchmarkRT [OPTIONS]
Options:
-b <type> - Specify the CMAKE_BUILD_TYPE.
The default value is "release".
Valid types are:
release
debug
minsizerel
relwithdebuginfo
-e - Specify the whole path to (but excluding) the "rawtherapee"
executable.
e.g. "-e $HOME/rt_${branch}_${buildType}"
-h - Print this help screen.
-i <file> - Input file name. This can be a file on your hard drive or a url.
-i <file> - Input file name with complete path. This can be a file on your hard drive or a url.
The url must start with "http". The default behavior if you do
not use -i is to download a test file from www.rawtherapee.com
-m <path> - Path to your clone of the RawTherapee source code repository.
The default path is ~/rawtherapee
If you do not specify a path and ~/rawtherapee is not found, it
will be cloned.
-r <rev> - You can try out any revision of RawTherapee.
Valid values are digits or the word "tip" (excluding quotation
marks), e.g.
1234
tip
-s <file> - Input sidecar file name. The name of the PP3 or XMP file by
which the input file must be developed.
This can be a file on your hard drive or a url.
-s <PP3-1> -s <PP3-2> -s <PP3-#> - Input sidecar file name(s) with full paths. You can specify '-s <PP3-#>' zero or more times. To specify multiple processing profiles, you must precede each file path with '-s'.
The processing profile can be a file on your hard drive or a url. Only one url is handled, so if you want to use multiple processing profiles, download them first.
The default behaviour if you do not use -s is to use the
"Neutral" profile.
@@ -66,8 +50,8 @@ Examples:
Run the default benchmark (recommended)
./benchmarkRT
Run a benchmark using your own files and existing RT clone dir
./benchmarkRT -b release -i kittens.raw -s kittens.raw.pp3 -m /home/fruitloops/rawtherapee-clone -r 4.0.0
Run a benchmark using your own image file, a RawTherpee executable in a custom directory, and multiple processing profiles:
./benchmarkRT -i /tmp/kittens.raw -s /tmp/kittens.raw.pp3 -s /tmp/kittens_tonemapped.raw.pp3 -s /tmp/kittens_denoised.raw.pp3
Further help:
If you need further help, discover bugs or want to request new functionality
@@ -78,53 +62,17 @@ Further help:
END
}
buildRT() {
[[ ! -e "${repo}/.hg/hgrc" ]] && {
printf "Error: Cannot find the RawTherapee source code repository in ${repo}\nEither run this script using the -m <path> option, or proceed and have the source code repository cloned automatically.\n" | fold -s
read -p "Do you want to proceed? y/n: " YN
[[ "$YN" != y ]] && exit 1
[[ ! -w /tmp ]] && { printf "Error: /tmp is not writable.\n"; exit 1; }
repo="${tmpDir}/repo"
hg clone https://rawtherapee.googlecode.com/hg/ "$repo"
}
cd "$repo"
hg pull
hg update -r "$revision" || {
printf "About to run \"hg update -C\" which will undo any changes you made to the cloned source code repository. YOU MIGHT LOSE YOUR WORK!\n"
read -p "Do you want to undo all uncommitted changes? y/n: " YN
[[ "$YN" != y ]] && exit 1
hg update -C
hg update -r "$revision" || { printf "Something went wrong while trying to update your cloned source code repository. Exiting.\n"; exit 1; }
}
make clean
./clean.sh
verLatestTag="`hg parents --template '{LATESTTAG}'`"
verMajor="${verLatestTag%%.*}"
cmake -DCMAKE_BUILD_TYPE="$buildType" -DPROC_TARGET_NUMBER:STRING=2 -DCMAKE_INSTALL_PREFIX=rawtherapee -DBUILD_BUNDLE=ON -DBINDIR=. -DDATADIR=. -DCACHE_NAME_SUFFIX="$verMajor"
cpuCount="`grep -c 'processor' /proc/cpuinfo`"
make -j"$cpuCount" install
mv "$buildType" "${tmpDir}/rt_${branch}_${buildType}"
rtExe="${tmpDir}/rt_${branch}_${buildType}/rawtherapee"
}
while getopts "e:h?r:i:s:m:b:" opt; do
while getopts "e:h?i:s:" opt; do
case "$opt" in
e) customExeDir="$OPTARG"
e) customExeDir="${OPTARG%/}"
;;
h|\?)
howto
exit 0
;;
r) revision="$OPTARG"
buildRT
;;
i) inFile="$OPTARG"
;;
s) sidecarCustom="$OPTARG"
;;
m) repo="$OPTARG"
;;
b) buildType="$OPTARG"
s) sidecarCustom+=("$OPTARG")
;;
esac
done
@@ -134,7 +82,6 @@ shift $((OPTIND-1))
[ "$1" = "--" ] && shift
# tmpDir = /tmp/rawtherapee-benchmark
# if buildRT got called then repo = "${tmpDir}/repo" else repo = ${HOME}/rawtherapee
inFileName="`basename ${inFile}`"
@@ -163,22 +110,21 @@ 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
printf "${sidecarCustom} not found in ${tmpDir}, downloading it.\n"
[[ ! -w /tmp ]] && { printf "Error: /tmp is not writable.\n"; exit 1; }
[[ ! -e "$tmpDir" ]] && mkdir "$tmpDir"
cd "$tmpDir"
wget -c --trust-server-names "$sidecarCustom"
fi
else # else if sidecarCustom does not start with an http
[[ ! -e "${sidecarCustom}" ]] && { # then check if it exists
printf "You specified \"-i ${sidecarCustom}\" but it doesn't exist."
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
}
unset sidecarFiles # just to be sure, since custom supports only 1 file.
done
unset sidecarFiles
sidecarDir=""
sidecarFiles="${sidecarCustom}"
sidecarFiles=("${sidecarCustom[@]}")
fi
else # if sidecarCustom was not specified, use the ones in sidecarDefault
sidecarDirs=("${tmpDir}/rt_${branch}_${buildType}/profiles/" "${tmpDir}/" "${repo}/rt_${branch}_${buildType}/profiles/" "${repo}/rtdata/profiles/" "$HOME/.config/RawTherapee4/profiles/")
sidecarDirs=("$HOME/rt_${branch}_${buildType}_patched/profiles/" "${tmpDir}/" "$HOME/.config/RawTherapee4/profiles/")
for dir in "${sidecarDirs[@]}"; do
for sidecar in "${sidecarDefault[@]}"; do
# echo "Checking for ${sidecar} in ${dir}"
@@ -198,7 +144,7 @@ else # if sidecarCustom was not specified, use the ones in sidecarDefault
sidecarFiles=("${sidecarDefault[@]}")
fi
rtExeDirs=("${customExeDir}" "${tmpDir}/rt_${branch}_${buildType}" "$HOME/rt_${branch}_${buildType}" "${repo}/rt_${branch}_${buildType}" "${repo}/release" "$HOME/rawtherapee/")
rtExeDirs=("${customExeDir}" "$HOME/rt_${branch}_${buildType}" "$HOME/rt_${branch}_${buildType}_patched" "$HOME/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 ]] && {
@@ -212,9 +158,8 @@ for rtExeDir in "${rtExeDirs[@]}"; do
done
if [[ ! -x "${rtExeDir}/${rtExe}" ]]; then
printf "%s\n" "Could not find the RawTherapee executable. Either re-run this script using the -e flag, or continue to have this script clone the source code repository and compile RawTherapee for you. For this to work, you need to have the correct dependencies installed - see http://rawtherapee.com/forum/viewtopic.php?f=10&t=3001#p22213" | fold -s
read -p "Do you want to proceed? y/n: " YN
[[ "$YN" = y ]] && buildRT || exit 0
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"
@@ -247,10 +192,10 @@ for sidecar in "${sidecarFiles[@]}"; 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"
benchmark+=("`\time -f %e "${rtExeDir}/${rtExe}" -o "$tmpDir" -p "${sidecarDir}${sidecar}" "$outFileFormat" -Y -c "${tmpDir}/${inFileName}" 2>&1 >/dev/null`")
printf "%b\n" "Benchmark ${sidecar} ${i}: ${benchmark[$i - 1]}"
printf "%b\n" "Benchmark ${sidecar##*/} ${i}: ${benchmark[$i - 1]}"
done
avg=$( { printf "scale=2; ("; IFS="+"; printf %s "${benchmark[*]}"; echo ") / ${#benchmark[@]}"; } | bc)
printf "%b\n" "Benchmark ${sidecar} average:\t${avg}"
printf "%b\n" "Benchmark ${sidecar##*/} average:\t${avg}" ""
done
printf "Total runtime:\t`IFS=+; bc -l <<< "${benchmark[*]}"`\n"