Skip to content

Add flag to measure recipe execution time#3099

Open
GeorgeLS wants to merge 2 commits intocasey:masterfrom
GeorgeLS:master
Open

Add flag to measure recipe execution time#3099
GeorgeLS wants to merge 2 commits intocasey:masterfrom
GeorgeLS:master

Conversation

@GeorgeLS
Copy link
Copy Markdown

As part of this PR, I have added a new simple feature for printing elapsed time of recipes.
The output format is really simple: <materialized_recipe> (<elapsed_time>).

Here's an example of two recipes and the output for those:

Recipe 1:

test:
    ...

Output:

test (Duration: <time>)

Recipe 2:

test arg:
    ...

Invocation:

just test server

Output:

test server (Duration: <time>)

The duration is reported as soon as the recipe finishes.

Please note that if you have recursive recipes where you basically invoke just inside the recipe, the time reporting won't be propagated to the recursive invocation. If you want to measure the inner-invoked recipe, just pass -t/--time to the inner just invocation.

Copy link
Copy Markdown
Owner

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments! There will be conflicts when rebasing, but the changes to the completion files won't be needed.

.arg(
Arg::new(arg::TIME)
.action(ArgAction::SetTrue)
.short('t')
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove the short flag. They're a scarce resource, so I try to allocate them in response to popular demand.

Suggested change
.short('t')

case "${cmd}" in
just)
opts="-E -n -g -f -q -u -v -d -c -e -l -s -h -V --alias-style --ceiling --check --chooser --clear-shell-args --color --command-color --cygpath --dotenv-filename --dotenv-path --dry-run --dump-format --explain --global-justfile --highlight --justfile --list-heading --list-prefix --list-submodules --group --no-aliases --no-deps --no-dotenv --no-highlight --one --quiet --allow-missing --set --shell --shell-arg --shell-command --tempdir --timestamp --timestamp-format --unsorted --unstable --verbose --working-directory --yes --changelog --choose --command --completions --dump --edit --evaluate --fmt --groups --init --json --list --man --request --show --summary --usage --variables --help --version [ARGUMENTS]..."
opts="-E -n -g -f -q -t -u -v -d -c -e -l -s -h -V --alias-style --ceiling --check --chooser --clear-shell-args --color --command-color --cygpath --dotenv-filename --dotenv-path --dry-run --dump-format --explain --global-justfile --highlight --justfile --list-heading --list-prefix --list-submodules --no-aliases --no-deps --no-dotenv --no-highlight --one --quiet --allow-missing --set --shell --shell-arg --shell-command --tempdir --time --timestamp --timestamp-format --unsorted --unstable --verbose --working-directory --yes --changelog --choose --command --completions --dump --edit --evaluate --fmt --groups --init --list --man --request --show --summary --usage --variables --help --version [ARGUMENTS]..."
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The completion scripts are now dynamically generated by calling into the binary, so this diff will go away when your rebase.

}
}

fn print_elapsed_recipe_time(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just inline this.


eprint!("{prefix}{recipe_name}");

for arg in recipe_args {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about including recipe args, they can be quite long.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants