-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathbuild-and-collect-pgo-profiles
More file actions
executable file
·94 lines (77 loc) · 2.77 KB
/
build-and-collect-pgo-profiles
File metadata and controls
executable file
·94 lines (77 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/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 " -o <directory> 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."
echo " -y Use for automated collection. No user input."
}
BASE="/Volumes/WebKit/BenchmarkProfiles/"
while getopts "o:a:d:yh" flag; do
case "${flag}" in
o) BASE=${OPTARG};;
a) APP=${OPTARG};;
d) BUILD=${OPTARG};;
y) NINPUT=true ;;
h)
DisplayHelp
exit;;
esac
done
if [[ -n $APP ]] ; then
echo "app: $APP"
fi
if [[ -n $BUILD ]]; then
echo "build: $BUILD"
fi
echo "base: $BASE"
if [ ! -z $APP ] && [ ! -z $BUILD ] ; then
echo "These flags (-a and -d) cannot be used together."
DisplayHelp
exit
fi
while [[ ! "$NINPUT" ]] ; 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, creating directory."
mkdir -p "$BASE"
fi
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
benchmarks=(jetstream3 speedometer3 motionmark)
if [[ -n $APP ]] ; then
run_benchmark_args=(--browser-path "$APP")
deployment_target=$(vtool -show-build "$APP"/Contents/Frameworks/JavaScriptCore.framework/Versions/A/JavaScriptCore | grep -m1 minos | tr -d -c .0-9)
else
run_benchmark_args=(--build-directory $BUILD)
deployment_target=$(vtool -show-build "$BUILD"/JavaScriptCore.framework/Versions/A/JavaScriptCore | grep -m1 minos | tr -d -c .0-9)
fi
# The reported target triple is based on an arbitrary binary (JavaScriptCore)
# and this machine's architecture.
target_triple=$(machine)-apple-macos${deployment_target}
COMPRESSED_PROFILE_SUB_PATH="Internal/WebKit/WebKitAdditions/Profiling/$target_triple"
SPTH='OpenSource/Tools/Scripts'
$SPTH/collect-pgo-profiles --benchmarks ${benchmarks[@]} --output-directory $BASE --compressed-profile-sub-path $COMPRESSED_PROFILE_SUB_PATH ${run_benchmark_args[@]}