Skip to content

Commit 6ce73eb

Browse files
committed
test
1 parent e33382b commit 6ce73eb

File tree

4 files changed

+604
-0
lines changed

4 files changed

+604
-0
lines changed
Lines changed: 199 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
name: Build Benchmark - Manual
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
branch:
7+
description: 'Branch to benchmark'
8+
required: false
9+
default: ''
10+
base_branch:
11+
description: 'Base branch for comparison'
12+
required: false
13+
default: 'develop'
14+
warmups:
15+
description: 'Number of warmup iterations'
16+
required: false
17+
default: '4'
18+
iterations:
19+
description: 'Number of measured iterations'
20+
required: false
21+
default: '7'
22+
23+
jobs:
24+
benchmark-head:
25+
name: Benchmark Head Branch
26+
runs-on: ubuntu-24.04
27+
timeout-minutes: 120
28+
29+
steps:
30+
- name: Determine branch to benchmark
31+
id: determine-branch
32+
run: |
33+
BRANCH="${{ github.event.inputs.branch }}"
34+
if [ -z "$BRANCH" ]; then
35+
BRANCH="${{ github.ref_name }}"
36+
fi
37+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
38+
echo "Benchmarking branch: $BRANCH"
39+
40+
- name: Checkout repository
41+
uses: actions/checkout@v4
42+
with:
43+
ref: ${{ steps.determine-branch.outputs.branch }}
44+
submodules: recursive
45+
46+
- name: Set up Java
47+
uses: actions/setup-java@v4
48+
with:
49+
distribution: 'temurin'
50+
java-version: '17'
51+
52+
- name: Setup Gradle
53+
uses: gradle/actions/setup-gradle@v4
54+
with:
55+
cache-read-only: true
56+
57+
- name: Install SDKMAN
58+
run: |
59+
curl -s "https://get.sdkman.io" | bash
60+
source "$HOME/.sdkman/bin/sdkman-init.sh"
61+
sdk version
62+
63+
- name: Install Gradle Profiler
64+
run: |
65+
source "$HOME/.sdkman/bin/sdkman-init.sh"
66+
sdk install gradleprofiler
67+
gradle-profiler --version
68+
69+
- name: Warm up build cache
70+
run: |
71+
./gradlew assembleInternalDebug --no-daemon
72+
73+
- name: Create dynamic scenarios file
74+
if: github.event.inputs.warmups != '4' || github.event.inputs.iterations != '7'
75+
run: |
76+
WARMUPS="${{ github.event.inputs.warmups }}"
77+
ITERATIONS="${{ github.event.inputs.iterations }}"
78+
79+
sed -i "s/warm-ups = 4/warm-ups = $WARMUPS/g" build_performance.scenarios
80+
sed -i "s/iterations = 7/iterations = $ITERATIONS/g" build_performance.scenarios
81+
82+
echo "Updated scenarios file with warmups=$WARMUPS, iterations=$ITERATIONS"
83+
84+
- name: Run Build Benchmarks
85+
run: |
86+
source "$HOME/.sdkman/bin/sdkman-init.sh"
87+
gradle-profiler --benchmark --scenario-file build_performance.scenarios --output-dir profile-out-head
88+
89+
- name: Upload Head Benchmark Results
90+
uses: actions/upload-artifact@v4
91+
with:
92+
name: benchmark-results-head-${{ github.run_number }}
93+
path: profile-out-head/**/*.csv
94+
retention-days: 30
95+
96+
benchmark-base:
97+
name: Benchmark Base Branch
98+
runs-on: ubuntu-24.04
99+
timeout-minutes: 120
100+
needs: benchmark-head
101+
102+
steps:
103+
- name: Determine base branch
104+
id: determine-base
105+
run: |
106+
BASE="${{ github.event.inputs.base_branch }}"
107+
echo "base=$BASE" >> $GITHUB_OUTPUT
108+
echo "Benchmarking base branch: $BASE"
109+
110+
- name: Checkout repository
111+
uses: actions/checkout@v4
112+
with:
113+
ref: ${{ steps.determine-base.outputs.base }}
114+
submodules: recursive
115+
116+
- name: Set up Java
117+
uses: actions/setup-java@v4
118+
with:
119+
distribution: 'temurin'
120+
java-version: '17'
121+
122+
- name: Setup Gradle
123+
uses: gradle/actions/setup-gradle@v4
124+
with:
125+
cache-read-only: true
126+
127+
- name: Install SDKMAN
128+
run: |
129+
curl -s "https://get.sdkman.io" | bash
130+
source "$HOME/.sdkman/bin/sdkman-init.sh"
131+
sdk version
132+
133+
- name: Install Gradle Profiler
134+
run: |
135+
source "$HOME/.sdkman/bin/sdkman-init.sh"
136+
sdk install gradleprofiler
137+
gradle-profiler --version
138+
139+
- name: Warm up build cache
140+
run: |
141+
./gradlew assembleInternalDebug --no-daemon
142+
143+
- name: Create dynamic scenarios file
144+
if: github.event.inputs.warmups != '4' || github.event.inputs.iterations != '7'
145+
run: |
146+
WARMUPS="${{ github.event.inputs.warmups }}"
147+
ITERATIONS="${{ github.event.inputs.iterations }}"
148+
149+
sed -i "s/warm-ups = 4/warm-ups = $WARMUPS/g" build_performance.scenarios
150+
sed -i "s/iterations = 7/iterations = $ITERATIONS/g" build_performance.scenarios
151+
152+
echo "Updated scenarios file with warmups=$WARMUPS, iterations=$ITERATIONS"
153+
154+
- name: Run Build Benchmarks
155+
run: |
156+
source "$HOME/.sdkman/bin/sdkman-init.sh"
157+
gradle-profiler --benchmark --scenario-file build_performance.scenarios --output-dir profile-out-base
158+
159+
- name: Upload Base Benchmark Results
160+
uses: actions/upload-artifact@v4
161+
with:
162+
name: benchmark-results-base-${{ github.run_number }}
163+
path: profile-out-base/**/*.csv
164+
retention-days: 30
165+
166+
compare-results:
167+
name: Compare Results
168+
runs-on: ubuntu-24.04
169+
needs: [benchmark-head, benchmark-base]
170+
if: always() && needs.benchmark-head.result == 'success' && needs.benchmark-base.result == 'success'
171+
172+
steps:
173+
- name: Checkout repository
174+
uses: actions/checkout@v4
175+
176+
- name: Download Head Results
177+
uses: actions/download-artifact@v4
178+
with:
179+
name: benchmark-results-head-${{ github.run_number }}
180+
path: profile-out-head
181+
182+
- name: Download Base Results
183+
uses: actions/download-artifact@v4
184+
with:
185+
name: benchmark-results-base-${{ github.run_number }}
186+
path: profile-out-base
187+
188+
- name: Compare Results
189+
run: |
190+
python3 scripts/benchmark-comparison.py \
191+
profile-out-head/benchmark.csv \
192+
profile-out-base/benchmark.csv
193+
194+
- name: Upload Comparison Report
195+
uses: actions/upload-artifact@v4
196+
with:
197+
name: benchmark-comparison-${{ github.run_number }}
198+
path: benchmark-result.md
199+
retention-days: 30
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Build Benchmark - Nightly
2+
3+
on:
4+
schedule:
5+
# Run nightly at 2 AM UTC (matching nightly.yml)
6+
- cron: '0 2 * * *'
7+
workflow_dispatch:
8+
# Allow manual triggering
9+
10+
jobs:
11+
benchmark-develop:
12+
name: Benchmark Develop Branch
13+
runs-on: ubuntu-24.04
14+
timeout-minutes: 120
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
ref: develop
21+
submodules: recursive
22+
23+
- name: Set up Java
24+
uses: actions/setup-java@v4
25+
with:
26+
distribution: 'temurin'
27+
java-version: '17'
28+
29+
- name: Setup Gradle
30+
uses: gradle/actions/setup-gradle@v4
31+
with:
32+
cache-read-only: true
33+
34+
- name: Install SDKMAN
35+
run: |
36+
curl -s "https://get.sdkman.io" | bash
37+
source "$HOME/.sdkman/bin/sdkman-init.sh"
38+
sdk version
39+
40+
- name: Install Gradle Profiler
41+
run: |
42+
source "$HOME/.sdkman/bin/sdkman-init.sh"
43+
sdk install gradleprofiler
44+
gradle-profiler --version
45+
46+
- name: Run Gradle Build (warm cache)
47+
run: |
48+
./gradlew assembleInternalDebug --no-daemon
49+
50+
- name: Run Build Benchmarks
51+
run: |
52+
source "$HOME/.sdkman/bin/sdkman-init.sh"
53+
gradle-profiler --benchmark --scenario-file build_performance.scenarios --output-dir profile-out
54+
55+
- name: Upload Benchmark Results
56+
uses: actions/upload-artifact@v4
57+
with:
58+
name: benchmark-results-develop-${{ github.run_number }}
59+
path: profile-out/**/*.csv
60+
retention-days: 30
61+
62+
- name: Generate Summary Report
63+
run: |
64+
python3 scripts/benchmark-comparison.py profile-out/benchmark.csv
65+
66+
- name: Upload Summary Report
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: benchmark-summary-${{ github.run_number }}
70+
path: benchmark-result.md
71+
retention-days: 30
72+
73+
benchmark-comparison:
74+
name: Compare with Previous Results
75+
runs-on: ubuntu-24.04
76+
needs: benchmark-develop
77+
if: success()
78+
79+
steps:
80+
- name: Checkout repository
81+
uses: actions/checkout@v4
82+
83+
- name: Download Current Results
84+
uses: actions/download-artifact@v4
85+
with:
86+
name: benchmark-results-develop-${{ github.run_number }}
87+
path: profile-out-current
88+
89+
- name: Compute Previous Run Number
90+
id: prev-run
91+
run: echo "previous=$(( ${{ github.run_number }} - 1 ))" >> $GITHUB_OUTPUT
92+
93+
- name: Download Previous Results
94+
uses: actions/download-artifact@v4
95+
continue-on-error: true
96+
with:
97+
name: benchmark-results-develop-${{ steps.prev-run.outputs.previous }}
98+
path: profile-out-previous
99+
100+
- name: Compare Results
101+
if: hashFiles('profile-out-previous/benchmark.csv') != ''
102+
run: |
103+
python3 scripts/benchmark-comparison.py \
104+
profile-out-current/benchmark.csv \
105+
profile-out-previous/benchmark.csv
106+
107+
- name: Generate Trend Summary
108+
if: hashFiles('profile-out-previous/benchmark.csv') != ''
109+
run: |
110+
echo "## Nightly Build Performance Trend" >> $GITHUB_STEP_SUMMARY
111+
echo "" >> $GITHUB_STEP_SUMMARY
112+
cat benchmark-result.md >> $GITHUB_STEP_SUMMARY
113+
114+
- name: Upload Comparison Report
115+
if: hashFiles('profile-out-previous/benchmark.csv') != ''
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: benchmark-comparison-${{ github.run_number }}
119+
path: benchmark-result.md
120+
retention-days: 30

build_performance.scenarios

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Gradle Profiler Build Performance Scenarios
2+
# This file defines three benchmark scenarios to measure build performance
3+
4+
# Scenario 1: Clean Build
5+
# Measures cold build performance with no incremental compilation
6+
clean-build {
7+
title = "Clean Build"
8+
versions = ["8.14"]
9+
tasks = ["assembleInternalDebug"]
10+
gradle-args = ["--no-build-cache", "--no-configuration-cache"]
11+
cleanup-tasks = ["clean"]
12+
warm-ups = 4
13+
iterations = 7
14+
15+
# Use daemon for consistency
16+
daemon = warm
17+
}
18+
19+
# Scenario 2: ABI Change
20+
# Measures incremental build performance when public API changes
21+
# This triggers recompilation of all dependent modules
22+
abi-change {
23+
title = "ABI Change (Incremental)"
24+
versions = ["8.14"]
25+
tasks = ["assembleInternalDebug"]
26+
gradle-args = ["--no-build-cache", "--no-configuration-cache"]
27+
28+
# Apply ABI change to a core utility class
29+
# Gradle profiler will modify a public method signature
30+
apply-abi-change-to = "app/src/main/java/com/duckduckgo/app/global/DispatcherProvider.kt"
31+
32+
warm-ups = 4
33+
iterations = 7
34+
daemon = warm
35+
}
36+
37+
# Scenario 3: Non-ABI Change
38+
# Measures incremental build performance when only implementation changes
39+
# Only the modified module needs recompilation
40+
non-abi-change {
41+
title = "Non-ABI Change (Incremental)"
42+
versions = ["8.14"]
43+
tasks = ["assembleInternalDebug"]
44+
gradle-args = ["--no-build-cache", "--no-configuration-cache"]
45+
46+
# Apply non-ABI change to the same file
47+
# Gradle profiler will modify method implementation without changing signature
48+
apply-non-abi-change-to = "app/src/main/java/com/duckduckgo/app/global/DispatcherProvider.kt"
49+
50+
warm-ups = 4
51+
iterations = 7
52+
daemon = warm
53+
}

0 commit comments

Comments
 (0)