-
-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load timer #405
base: main
Are you sure you want to change the base?
Load timer #405
Conversation
@Tearran IMHO it would be PITA to maintain two copies of What about using an env var (eg,
Then in # disable set_checkpoint if DEBUG has not been defined
[[ -n "$DEBUG" ]] || eval "set_checkpoint(){ :; }" |
Yes, I would also propose to have one. |
remove redundant file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tearran I was under the impression that we only wanted timing info for debugging purposes. I kinda like that it's printed every time, but I don't know if there might be objections in terms of performance or some other reasons.
# Conditional settings based on arguments | ||
# for interactive vs non-interactive modes | ||
if [[ "$1" == "--api" || "$1" == "--doc" ]]; then | ||
UXMODE="false" | ||
elif [[ -z "$1" || "$1" == "--cmd" || "$1" == "--help" ]]; then | ||
UXMODE="true" | ||
fi | ||
|
||
# Additional check for interactive vs non-interactive mode | ||
if [[ ! -t 0 ]]; then | ||
UXMODE="false" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW can be replaced with:
unset UXMODE
[[ -t 0 && "$1" =~ ^(|--cmd|--help)$ ]] && UXMODE="true"
help) | ||
echo "Usage: set_checkpoint <start|stop|mark|show> [description] [show]" | ||
echo "Commands:" | ||
echo " start Start the timer." | ||
echo " stop Stop the timer." | ||
echo " mark [description] [time] Mark a checkpoint with an optional description and an optional flag to show the output." | ||
echo " show Show the total elapsed time and checkpoints." | ||
;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing indent? Same for other cases.
local checkpoint_time=${set_checkpoint_CHECKPOINTS[$i]} | ||
local checkpoint_duration=$((checkpoint_time - previous_time)) | ||
local description=${set_checkpoint_DESCRIPTIONS[$i]} | ||
printf "%-30s: %d seconds\n" "${description:-Checkpoint $((i+1))}" "${checkpoint_duration}" | ||
previous_time=$checkpoint_time |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing indent inside for-loop?
local checkpoint_time=$(date +%s) | ||
local checkpoint_duration=$((checkpoint_time - set_checkpoint_PREV)) | ||
set_checkpoint_PREV=$checkpoint_time | ||
set_checkpoint_CHECKPOINTS+=($checkpoint_time) | ||
set_checkpoint_DESCRIPTIONS+=("$2") | ||
local count=${#set_checkpoint_DESCRIPTIONS[@]} | ||
if [[ "$3" == "true" && $UXMODE == "true" ]]; then | ||
printf "%-30s %10d seconds\n" "$2:" "${checkpoint_duration}" | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick, but if you do this, you can avoid unnecessary calculations in non-UX mode:
mark)
if [[ "$UXMODE" == "true" ]]; then
local checkpoint_time=$(date +%s)
local checkpoint_duration=$((checkpoint_time - set_checkpoint_PREV))
set_checkpoint_PREV=$checkpoint_time
set_checkpoint_CHECKPOINTS+=($checkpoint_time)
set_checkpoint_DESCRIPTIONS+=("$2")
local count=${#set_checkpoint_DESCRIPTIONS[@]}
[[ "$3" == "true" ]] && printf "%-30s %10d seconds\n" "$2:" "${checkpoint_duration}"
fi
;;
@dimitry-ishenko I am not opposed to using a DEBUG environment variable in general. However, I would like to clarify that the messages displayed are not meant for debugging purposes and are not being introduced with this PR. These messages were previously implemented to improve the user experience by indicating that the application is working and not frozen. In other words, this PR does not address bugs. Rather, it outlines the expected parsing load time limitations due to the linear nature of bash, such as function variable racing and other inherent constraints. The addition of the timestamp is multifaceted. Firstly, IMHO it is important to recognize the limitations of bash, so that expected limitations are not identified as bugs. Showing loading time addresses this by clearly showing expected behavior. For example, 4 seconds may be undesirable but it is not a bug. By providing these user-facing messages, we aim to enhance user experience by transparently communicating the application's activity, thus avoiding any misconceptions of the application being unresponsive. |
@Tearran sorry, not sure why I got the idea this was for debugging. Thanks for the clear explanation, it makes sense. |
Description
refinement of #326
Added a Timer function to help identify sections that are slow and may need optimization or separation to improve performance.
./tools/armbian-config-dev
and./bin/armbian-config
./bin/armbian-config --api set_checkpoint help
Issue reference:
[Bug]: sanitize_input #324
function raceing
Partly addresses UX vs Non interactive mode use
Implementation Details
Checklist