blob: e417b6dfdcdc4d573015437e42ad9ba8e42d600e [file] [log] [blame]
#!/bin/bash
set -e
set -o pipefail
# Build WebKit, run benchmarks, and spit out compressed PGO profiles
DisplayHelp() {
echo "Usage: build-and-collect-pgo-profiles [ options ]"
echo " -h Show this help message."
echo " -b <directory> Base directory in which output files are stored. Default: /Volumes/WebKit/BenchmarkProfiles/."
echo " -a <app> Path to Safari.app to generate profiles for. If not specified, the script will build WebKit."
echo " -d <directory> Path to build directory. Use seperately from -a."
}
BASE="/Volumes/WebKit/BenchmarkProfiles/"
while getopts "b:a:d:h" flag; do
case "${flag}" in
b) BASE=${OPTARG};;
a) APP=${OPTARG};;
d) BUILD=${OPTARG};;
h)
DisplayHelp
exit;;
esac
done
echo "app: $APP"
echo "build: $BUILD"
echo "base: $BASE"
if [ ! -z $APP ] && [ ! -z $BUILD ] ; then
echo "These flags (-a and -d) cannot be used together."
DisplayHelp
exit
fi
while true; do
read -p "Have you read the source of this script, and do you understand that it is potentially destructive? [y/N]" yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo "Using output directory: $BASE"
if [[ ! -d "$BASE" ]] ; then
echo "$BASE is missing, aborting."
DisplayHelp
exit
fi
rm -rf "$BASE/*"
mkdir -p "$BASE/speedometer"
mkdir -p "$BASE/jetstream"
mkdir -p "$BASE/motionmark"
mkdir -p "$BASE/output"
mkdir -p "$BASE/Internal/WebKit/WebKitAdditions/Profiling/"
if [[ -z $APP ]] ; then
cd Internal
echo "Building WebKit..."
rm -rf ../OpenSource/WebKitBuild
make release WK_LTO_MODE=thin ENABLE_LLVM_PROFILE_GENERATION=ON
cd ../
else
if [[ ! -e "$APP" ]] ; then
echo "$APP is missing, aborting."
DisplayHelp
exit
fi
echo "Using .app: $APP"
fi
jsargs=(
--plan jetstream2
--diagnose-directory="$BASE/jetstream"
--generate-profiles
--count 1
)
spargs=(
--plan speedometer2
--diagnose-directory="$BASE/speedometer"
--generate-profiles
--count 1
)
mmargs=(
--plan motionmark1.1
--diagnose-directory="$BASE/motionmark"
--generate-profiles
--count 1
)
if [[ -n $APP ]] ; then
jsargs+=(--browser-path "$APP")
spargs+=(--browser-path "$APP")
mmargs+=(--browser-path "$APP")
else
jsargs+=(--build-directory $BUILD)
spargs+=(--build-directory $BUILD)
mmargs+=(--build-directory $BUILD)
fi
SPTH='OpenSource/Tools/Scripts'
$SPTH/run-benchmark "${jsargs[@]}"
$SPTH/pgo-profile merge "$BASE/jetstream"
$SPTH/run-benchmark "${spargs[@]}"
$SPTH/pgo-profile merge "$BASE/speedometer"
$SPTH/run-benchmark "${mmargs[@]}"
$SPTH/pgo-profile merge "$BASE/motionmark"
rm *.result
$SPTH/pgo-profile combine --jetstream "$BASE/jetstream" --speedometer "$BASE/speedometer" --motionmark "$BASE/motionmark" --output "$BASE/output"
$SPTH/pgo-profile compress --input "$BASE/output" --output "$BASE/Internal/WebKit/WebKitAdditions/Profiling/"
echo "Done! Find your profiles in $BASE/Internal/WebKit/WebKitAdditions/Profiling/"
echo "To check these in, do: 'cp -r $BASE/Internal/ ../Internal/'"