-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(instrumentation): add build step duration tracking
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
declare -A all_build_step_times | ||
|
||
print_time() { | ||
local t="$1" | ||
printf '%02dh:%02dm:%02ds\n' $((t/3600)) $((t%3600/60)) $((t%60)) | ||
} | ||
|
||
store_build_step_duration() { | ||
local step_label=$1 | ||
local start=$2 | ||
local end=$(date +%s) | ||
local duration=$(($end-$start)) | ||
all_build_step_times["$step_label"]="$duration" | ||
} | ||
|
||
print_build_step_duration() { | ||
local step_label=$1 | ||
local start=$2 | ||
local end=$(date +%s) | ||
local duration=$(($end-$start)) | ||
printf "[build time] $step_label:"'\t'"$(print_time "$duration")"'\n' | ||
} | ||
|
||
print_total_build_time_info() { | ||
local total_build_end=$(date +%s) | ||
local total_build_duration=$(($total_build_end-$start_time_build)) | ||
local accounted_for_total=0 | ||
echo | ||
echo "**build step durations**" | ||
for label in "${!all_build_step_times[@]}"; do | ||
local d="${all_build_step_times[$label]}" | ||
printf "[build time] $label:"'\t'"$(print_time "$d")"'\n' | ||
accounted_for_total=$(($accounted_for_total+$d)) | ||
done | ||
|
||
echo ---------------------------------------- | ||
echo "**summary**" | ||
print_build_step_duration "**total build time**" "$start_time_build" | ||
|
||
# check that we are actually measuring all relevant build steps: | ||
local unaccounted=$(($total_build_duration-$accounted_for_total)) | ||
printf "[build time] build time account for by individual build steps:"'\t'"$(print_time "$accounted_for_total")"'\n' | ||
printf "[build time] build time unaccounted for by individual build steps:"'\t'"$(print_time "$unaccounted")"'\n' | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters