From 30c3b0576cc443970ab280e7ec596dd2ac80a6f4 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sat, 2 Nov 2024 19:29:44 +0100 Subject: [PATCH] new: dev: [compose-core] add some more timing in debug mode --- bin/compose-core | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/bin/compose-core b/bin/compose-core index d8e6189..60fd2f9 100755 --- a/bin/compose-core +++ b/bin/compose-core @@ -5471,12 +5471,24 @@ aexport remainder_args ## Actual code ## +if [ -n "$DEBUG" ]; then + Elt "compute hashes" + start=$(time_now) +fi + COMPOSE_YML_FILE=$(get_compose_yml_location) || exit 1 COMPOSE_YML_CONTENT=$(get_compose_yml_content) || exit 1 COMPOSE_YML_CONTENT_HASH=$(compose:yml:hash) || exit 1 CHARM_STORE_HASH=$(charm.store_metadata_hash) || exit 1 COMBINED_HASH=$(H "$COMPOSE_YML_CONTENT_HASH" "$CHARM_STORE_HASH") || exit 1 export COMPOSE_YML_FILE COMPOSE_YML_CONTENT COMPOSE_YML_CONTENT_HASH CHARM_STORE_HASH COMBINED_HASH + +if [ -n "$DEBUG" ]; then + elapsed="$(time_elapsed $start "$(time_now)")" || exit 1 + print_info "$(printf "%.3fs" "$elapsed")" + Feedback +fi + charm.sanity_checks || die "Sanity checks about charm-store failed. Please correct." ## @@ -5821,6 +5833,10 @@ state:fields:resolve-parallel() { export -f state:fields:resolve-parallel if [ "$action" == "status" ]; then + if [ -n "$DEBUG" ]; then + start=$(time_now) + fi + if ! [ -t 1 ]; then state_raw_output=1 fi @@ -6092,6 +6108,12 @@ if [ "$action" == "status" ]; then echo " ${GRAY}..${NORMAL} ${WHITE}Exited${NORMAL} with errorlevel ${DARKRED}$E${NORMAL}" >&2 done if [[ "${#errors[@]}" -gt 0 ]]; then + if [ -n "$DEBUG" ]; then + Elt "table computation ${DARKRED}failed${NORMAL}" + elapsed="$(time_elapsed $start "$(time_now)")" || exit 1 + print_info "${elapsed}s" + Feedback + fi exit 1 fi @@ -6122,7 +6144,12 @@ if [ "$action" == "status" ]; then fi done fi - + if [ -n "$DEBUG" ]; then + Elt "table computation ${GREEN}successful${NORMAL}" + elapsed="$(time_elapsed $start "$(time_now)")" || exit 1 + print_info "${elapsed}s" + Feedback + fi exit 0 fi