Title: [295598] trunk/Tools/Scripts/build-and-collect-pgo-profiles
Revision
295598
Author
commit-qu...@webkit.org
Date
2022-06-16 10:32:25 -0700 (Thu, 16 Jun 2022)

Log Message

Extend build-and-collect-pgo-profiles to support testing a browser path
https://bugs.webkit.org/show_bug.cgi?id=241392
rdar://94581810

Patch by briannafan <brian...@berkeley.edu> on 2022-06-16
Reviewed by Dewei Zhu.

Extending script to take browser path and skip building.

* Tools/Scripts/build-and-collect-pgo-profiles:

Canonical link: https://commits.webkit.org/251603@main

Modified Paths

Diff

Modified: trunk/Tools/Scripts/build-and-collect-pgo-profiles (295597 => 295598)


--- trunk/Tools/Scripts/build-and-collect-pgo-profiles	2022-06-16 16:39:55 UTC (rev 295597)
+++ trunk/Tools/Scripts/build-and-collect-pgo-profiles	2022-06-16 17:32:25 UTC (rev 295598)
@@ -3,9 +3,38 @@
 set -o pipefail
 
 # Build WebKit, run benchmarks, and spit out compressed PGO profiles
-BASE=${1:-/Volumes/WebKit/BenchmarkProfiles/}
-echo "Using output directory: $BASE"
 
+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
@@ -15,8 +44,11 @@
     esac
 done
 
+echo "Using output directory: $BASE"
+
 if [[ ! -d "$BASE" ]] ; then
     echo "$BASE is missing, aborting."
+    DisplayHelp
     exit
 fi
 
@@ -28,25 +60,68 @@
 mkdir -p "$BASE/output"
 mkdir -p "$BASE/Internal/WebKit/WebKitAdditions/Profiling/"
 
-cd ../Internal
+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
 
-rm -rf ../OpenSource/WebKitBuild
-make release WK_LTO_MODE=thin ENABLE_LLVM_PROFILE_GENERATION=ON
+jsargs=(
+    --plan jetstream2
+    --diagnose-directory="$BASE/jetstream"
+    --generate-profiles
+    --count 1
+)
 
-run-benchmark --plan jetstream2 --diagnose-directory="$BASE/jetstream" --generate-profiles --build-directory=../OpenSource/WebKitBuild/Release --count 1
-pgo-profile merge "$BASE/jetstream"
+spargs=(
+    --plan speedometer2
+    --diagnose-directory="$BASE/speedometer"
+    --generate-profiles
+    --count 1
+)
 
-run-benchmark --plan speedometer --diagnose-directory="$BASE/speedometer" --generate-profiles --build-directory=../OpenSource/WebKitBuild/Release --count 1
-pgo-profile merge "$BASE/speedometer"
+mmargs=(
+    --plan motionmark1.1
+    --diagnose-directory="$BASE/motionmark"
+    --generate-profiles
+    --count 1
+)
 
-run-benchmark --plan motionmark --diagnose-directory="$BASE/motionmark" --generate-profiles --build-directory=../OpenSource/WebKitBuild/Release --count 1
-pgo-profile merge "$BASE/motionmark"
+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
 
-pgo-profile combine --jetstream "$BASE/jetstream" --speedometer "$BASE/speedometer" --motionmark "$BASE/motionmark" --output "$BASE/output"
+$SPTH/pgo-profile combine --jetstream "$BASE/jetstream" --speedometer "$BASE/speedometer" --motionmark "$BASE/motionmark" --output "$BASE/output"
 
-pgo-profile compress --input "$BASE/output" --output "$BASE/Internal/WebKit/WebKitAdditions/Profiling/"
+$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/'"
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to