blob: e417b6dfdcdc4d573015437e42ad9ba8e42d600e [file] [log] [blame]
commit-queue@webkit.org16463e92022-04-20 19:30:06 +00001#!/bin/bash
2set -e
3set -o pipefail
4
5# Build WebKit, run benchmarks, and spit out compressed PGO profiles
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +00006
7DisplayHelp() {
8 echo "Usage: build-and-collect-pgo-profiles [ options ]"
9 echo " -h Show this help message."
10 echo " -b <directory> Base directory in which output files are stored. Default: /Volumes/WebKit/BenchmarkProfiles/."
11 echo " -a <app> Path to Safari.app to generate profiles for. If not specified, the script will build WebKit."
12 echo " -d <directory> Path to build directory. Use seperately from -a."
13}
14
15BASE="/Volumes/WebKit/BenchmarkProfiles/"
16
17while getopts "b:a:d:h" flag; do
18 case "${flag}" in
19 b) BASE=${OPTARG};;
20 a) APP=${OPTARG};;
21 d) BUILD=${OPTARG};;
22 h)
23 DisplayHelp
24 exit;;
25 esac
26done
27
28echo "app: $APP"
29echo "build: $BUILD"
30echo "base: $BASE"
31
32if [ ! -z $APP ] && [ ! -z $BUILD ] ; then
33 echo "These flags (-a and -d) cannot be used together."
34 DisplayHelp
35 exit
36fi
commit-queue@webkit.org16463e92022-04-20 19:30:06 +000037
38while true; do
39 read -p "Have you read the source of this script, and do you understand that it is potentially destructive? [y/N]" yn
40 case $yn in
41 [Yy]* ) break;;
42 [Nn]* ) exit;;
43 * ) echo "Please answer yes or no.";;
44 esac
45done
46
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +000047echo "Using output directory: $BASE"
48
commit-queue@webkit.org16463e92022-04-20 19:30:06 +000049if [[ ! -d "$BASE" ]] ; then
50 echo "$BASE is missing, aborting."
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +000051 DisplayHelp
commit-queue@webkit.org16463e92022-04-20 19:30:06 +000052 exit
53fi
54
55rm -rf "$BASE/*"
56
57mkdir -p "$BASE/speedometer"
58mkdir -p "$BASE/jetstream"
justin_michaud@apple.com64892392022-05-06 18:37:28 +000059mkdir -p "$BASE/motionmark"
commit-queue@webkit.org16463e92022-04-20 19:30:06 +000060mkdir -p "$BASE/output"
61mkdir -p "$BASE/Internal/WebKit/WebKitAdditions/Profiling/"
62
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +000063if [[ -z $APP ]] ; then
64 cd Internal
65 echo "Building WebKit..."
66 rm -rf ../OpenSource/WebKitBuild
67 make release WK_LTO_MODE=thin ENABLE_LLVM_PROFILE_GENERATION=ON
68 cd ../
69else
70 if [[ ! -e "$APP" ]] ; then
71 echo "$APP is missing, aborting."
72 DisplayHelp
73 exit
74 fi
75 echo "Using .app: $APP"
76fi
commit-queue@webkit.org16463e92022-04-20 19:30:06 +000077
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +000078jsargs=(
79 --plan jetstream2
80 --diagnose-directory="$BASE/jetstream"
81 --generate-profiles
82 --count 1
83)
commit-queue@webkit.org16463e92022-04-20 19:30:06 +000084
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +000085spargs=(
86 --plan speedometer2
87 --diagnose-directory="$BASE/speedometer"
88 --generate-profiles
89 --count 1
90)
commit-queue@webkit.org16463e92022-04-20 19:30:06 +000091
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +000092mmargs=(
93 --plan motionmark1.1
94 --diagnose-directory="$BASE/motionmark"
95 --generate-profiles
96 --count 1
97)
commit-queue@webkit.org16463e92022-04-20 19:30:06 +000098
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +000099if [[ -n $APP ]] ; then
100 jsargs+=(--browser-path "$APP")
101 spargs+=(--browser-path "$APP")
102 mmargs+=(--browser-path "$APP")
103else
104 jsargs+=(--build-directory $BUILD)
105 spargs+=(--build-directory $BUILD)
106 mmargs+=(--build-directory $BUILD)
107fi
108
109SPTH='OpenSource/Tools/Scripts'
110
111$SPTH/run-benchmark "${jsargs[@]}"
112$SPTH/pgo-profile merge "$BASE/jetstream"
113
114$SPTH/run-benchmark "${spargs[@]}"
115$SPTH/pgo-profile merge "$BASE/speedometer"
116
117$SPTH/run-benchmark "${mmargs[@]}"
118$SPTH/pgo-profile merge "$BASE/motionmark"
justin_michaud@apple.com64892392022-05-06 18:37:28 +0000119
commit-queue@webkit.org16463e92022-04-20 19:30:06 +0000120rm *.result
121
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +0000122$SPTH/pgo-profile combine --jetstream "$BASE/jetstream" --speedometer "$BASE/speedometer" --motionmark "$BASE/motionmark" --output "$BASE/output"
commit-queue@webkit.org16463e92022-04-20 19:30:06 +0000123
commit-queue@webkit.org2d8bf282022-06-16 17:32:25 +0000124$SPTH/pgo-profile compress --input "$BASE/output" --output "$BASE/Internal/WebKit/WebKitAdditions/Profiling/"
commit-queue@webkit.org16463e92022-04-20 19:30:06 +0000125
126echo "Done! Find your profiles in $BASE/Internal/WebKit/WebKitAdditions/Profiling/"
justin_michaud@apple.com64892392022-05-06 18:37:28 +0000127echo "To check these in, do: 'cp -r $BASE/Internal/ ../Internal/'"