Skip to content

Commit da175ff

Browse files
authored
Merge pull request #262 from gradle/erichaagdev/exp1-display-realized-build-time-savings
Include performance characteristics and support `-x` for Gradle experiment 1
2 parents d4ca410 + 5fe7863 commit da175ff

File tree

3 files changed

+125
-22
lines changed

3 files changed

+125
-22
lines changed

components/scripts/gradle/01-validate-incremental-building.sh

Lines changed: 121 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ ge_server=''
3939
interactive_mode=''
4040

4141
main() {
42+
if [[ "$build_scan_publishing_mode" == "off" ]]; then
43+
verify_build_scan_support_tool_exists
44+
fi
45+
4246
if [ "${interactive_mode}" == "on" ]; then
4347
wizard_execute
4448
else
@@ -63,6 +67,9 @@ execute() {
6367
execute_second_build
6468
rename_project_dir "build_${project_name}" "second-build_${project_name}"
6569

70+
print_bl
71+
fetch_build_cache_metrics
72+
6673
print_bl
6774
print_summary
6875
}
@@ -71,8 +78,16 @@ wizard_execute() {
7178
print_bl
7279
print_introduction
7380

74-
print_bl
75-
explain_prerequisites_ccud_gradle_plugin ""
81+
if [[ "${build_scan_publishing_mode}" == "on" ]]; then
82+
print_bl
83+
explain_prerequisites_ccud_gradle_plugin "I."
84+
85+
print_bl
86+
explain_prerequisites_api_access "II."
87+
else
88+
print_bl
89+
explain_prerequisites_ccud_gradle_plugin
90+
fi
7691

7792
print_bl
7893
explain_collect_git_details
@@ -106,23 +121,57 @@ wizard_execute() {
106121
print_bl
107122
explain_measure_build_results
108123
print_bl
124+
fetch_build_cache_metrics
125+
print_bl
109126
explain_and_print_summary
110127
}
111128

129+
# shellcheck disable=SC2086 # splitting expected
112130
execute_first_build() {
113131
info "Running first build:"
114-
info "./gradlew --no-build-cache --scan -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} clean ${tasks}$(print_extra_args)"
115-
116-
# shellcheck disable=SC2086 # we want tasks to expand with word splitting in this case
117-
invoke_gradle --no-build-cache clean ${tasks}
132+
execute_build clean ${tasks}
118133
}
119134

135+
# shellcheck disable=SC2086 # splitting expected
120136
execute_second_build() {
121137
info "Running second build:"
122-
info "./gradlew --no-build-cache --scan -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} ${tasks}$(print_extra_args)"
138+
execute_build ${tasks}
139+
}
140+
141+
execute_build() {
142+
print_gradle_command "$@"
143+
invoke_gradle --no-build-cache "$@"
144+
}
123145

124-
# shellcheck disable=SC2086 # we want tasks to expand with word splitting in this case
125-
invoke_gradle --no-build-cache ${tasks}
146+
print_gradle_command() {
147+
local scan_arg
148+
if [[ "${build_scan_publishing_mode}" == "on" ]]; then
149+
scan_arg="--scan"
150+
else
151+
scan_arg="-Dscan.dump"
152+
fi
153+
info "./gradlew --no-build-cache ${scan_arg} -Dscan.tag.${EXP_SCAN_TAG} -Dscan.value.runId=${RUN_ID} $*$(print_extra_args)"
154+
}
155+
156+
fetch_build_cache_metrics() {
157+
if [ "$build_scan_publishing_mode" == "on" ]; then
158+
read_build_scan_metadata
159+
fetch_and_read_build_scan_data build_cache_metrics_only "${build_scan_urls[@]}"
160+
else
161+
find_and_read_build_scan_dumps
162+
fi
163+
}
164+
165+
# Overrides info.sh#print_performance_metrics
166+
print_performance_metrics() {
167+
print_performance_characteristics
168+
}
169+
170+
# Overrides info.sh#print_performance_characteristics
171+
print_performance_characteristics() {
172+
print_performance_characteristics_header
173+
174+
print_realized_build_time_savings
126175
}
127176

128177
print_quick_links() {
@@ -216,33 +265,74 @@ EOF
216265

217266
explain_measure_build_results() {
218267
local text
219-
IFS='' read -r -d '' text <<EOF
268+
if [[ "${build_scan_publishing_mode}" == "on" ]]; then
269+
IFS='' read -r -d '' text <<EOF
220270
$(print_separator)
221271
${HEADER_COLOR}Measure build results${RESTORE}
222272
223-
Now that the second build has finished successfully, you are ready to measure in
224-
Gradle Enterprise how well your build leverages Gradle’s incremental build
273+
Now that the second build has finished successfully, you are ready to measure
274+
in Gradle Enterprise how well your build leverages Gradle’s incremental build
225275
functionality for the invoked set of Gradle tasks.
226276
277+
Some of the build scan data will be fetched from the build scans produced by
278+
the two builds to assist you in your investigation.
279+
227280
${USER_ACTION_COLOR}Press <Enter> to measure the build results.${RESTORE}
228281
EOF
282+
else
283+
IFS='' read -r -d '' text <<EOF
284+
$(print_separator)
285+
${HEADER_COLOR}Measure build results${RESTORE}
286+
287+
Now that the second build has finished successfully, you are ready to measure
288+
how well your build leverages Gradle’s incremental build functionality for the
289+
invoked set of Gradle tasks.
290+
291+
Some of the build scan data will be extracted from the locally stored,
292+
intermediate build data produced by the two builds to assist you in your
293+
investigation.
294+
295+
${USER_ACTION_COLOR}Press <Enter> to measure the build results.${RESTORE}
296+
EOF
297+
fi
229298
print_wizard_text "${text}"
230299
wait_for_enter
231300
}
232301

233302
explain_and_print_summary() {
234303
read_build_scan_metadata
235304
local text
236-
IFS='' read -r -d '' text <<EOF
237-
The 'Summary' section below captures the configuration of the experiment and the
238-
two build scans that were published as part of running the experiment. The build
239-
scan of the second build is particularly interesting since this is where you can
240-
inspect what tasks were not leveraging Gradle’s incremental build functionality.
305+
if [[ "${build_scan_publishing_mode}" == "on" ]]; then
306+
IFS='' read -r -d '' text <<EOF
307+
The ‘Summary’ section below captures the configuration of the experiment and
308+
the two build scans that were published as part of running the experiment. The
309+
build scan of the second build is particularly interesting since this is where
310+
you can inspect what tasks were not leveraging Gradle’s incremental build
311+
functionality.
312+
313+
$(explain_performance_characteristics)
314+
315+
The ‘Investigation Quick Links’ section below allows quick navigation to the
316+
most relevant views in build scans to investigate what tasks were up-to-date
317+
and what tasks executed in the second build, which of those tasks had the
318+
biggest impact on build performance, and what caused those tasks to not be
319+
up-to-date.
320+
321+
$(explain_command_to_repeat_experiment)
322+
323+
$(print_summary)
324+
325+
$(print_command_to_repeat_experiment)
326+
327+
$(explain_when_to_rerun_experiment)
328+
EOF
329+
else
330+
IFS='' read -r -d '' text <<EOF
331+
The ‘Summary’ section below captures the configuration of the experiment. No
332+
build scans are available for inspection since publishing was disabled for the
333+
experiment.
241334
242-
The 'Investigation Quick Links' section below allows quick navigation to the
243-
most relevant views in build scans to investigate what tasks were uptodate and
244-
what tasks executed in the second build, which of those tasks had the biggest
245-
impact on build performance, and what caused those tasks to not be uptodate.
335+
$(explain_performance_characteristics)
246336
247337
$(explain_command_to_repeat_experiment)
248338
@@ -252,8 +342,18 @@ $(print_command_to_repeat_experiment)
252342
253343
$(explain_when_to_rerun_experiment)
254344
EOF
345+
fi
255346
print_wizard_text "${text}"
256347
}
257348

349+
explain_performance_characteristics() {
350+
local text
351+
IFS='' read -r -d '' text <<EOF
352+
The ‘Performance Characteristics’ section below reveals the realized build time
353+
savings as a result of leveraging Gradle’s incremental build functionality.
354+
EOF
355+
echo -n "${text}"
356+
}
357+
258358
process_arguments "$@"
259359
main

components/scripts/lib/cli-parsers/gradle/01-cli-parser.m4

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
# shellcheck disable=SC2034 # It is common for variables in this auto-generated file to go unused
33
# Created by argbash-init v2.10.0
4+
# ARG_OPTIONAL_BOOLEAN([disable-build-scan-publishing],[x],[])
45
# ARG_HELP([This function is overridden later on.])
56
# ARG_VERSION([print_version],[v],[version],[])
67
# ARGBASH_WRAP([common])
@@ -27,6 +28,7 @@ function print_help() {
2728
print_option_usage -a
2829
print_option_usage -s
2930
print_option_usage -e
31+
print_option_usage -x
3032
print_option_usage -v
3133
print_option_usage -h
3234
}

release/changes.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
- [NEW] Include realized build time savings in experiment summary
1+
- [NEW] Include realized build time savings in all experiment summaries
2+
- [NEW] Support `-x` command line option for Gradle experiment 1

0 commit comments

Comments
 (0)