mise icon indicating copy to clipboard operation
mise copied to clipboard

feat(tasks): add --timings option for run command

Open Ajpantuso opened this issue 1 year ago • 1 comments

Summary

Closed #1265

Adds a --show-timings option to the mise run command to display elapsed time after each task.

Open Questions

  • Should timings be shown even after failure?
  • Should total time also be displayed after all tasks have run?
  • What style/format would look best for the new output?

Ajpantuso avatar Jan 26 '24 22:01 Ajpantuso

let's just call it --timings—with a hidden alias --timing

jdx avatar Jan 26 '24 22:01 jdx

Since tasks might run in parallel the task prefix should probably be added to be able to tell which timing belongs to what task. The current output does not make that clear. Screenshot 2024-01-29 at 10 45 12

roele avatar Jan 29 '24 13:01 roele

@roele yeah I figured that would happen since we are streaming stdout/stderr; was just getting lucky on my test runs.

How would you feel about just adding a summary report of timings after all parallel execution? I already added a metrics recorder for this purpose so there could eventually be structured output options. I guess prefixed output would be okay as well just think it may be hard to read with many tasks or lots of output.

Ajpantuso avatar Jan 29 '24 13:01 Ajpantuso

Yes prefixed will help a little but with many tasks could still be hard to read. An overall summary at the end might be better. Maybe we can find some good examples from other tools.

Screenshot 2024-01-29 at 11 10 57

roele avatar Jan 29 '24 14:01 roele

@roele cool, added prefixes for now just so folks can review what it would look like. In parallel I'll play around with summary formats.

Ajpantuso avatar Jan 29 '24 14:01 Ajpantuso

@roele I have a quick summary table implementation here if you wanted to review/refine it.

After looking at it I feel like hacking a table on to the default output doesn't look right. I think a --summarize or --summary option in the future would feel more natural. The default summary could just be a user-consumable table with no stdout/stderr from tasks while additional output options like ---output={json,yaml,...} could dump stdout/stderr from tasks into a structured format for processing by CI runners.

Ajpantuso avatar Jan 29 '24 16:01 Ajpantuso

I might be not understanding this so much but I think this could be simplified by doing something like this:

fn run_all() {
  let start = time::Instant::now()
  for task in tasks {
    task.run();
  }
  println!("elapsed all: ...")
}

fn run_task() {
  let start = time::Instant::now()
  run()
  println!("elapsed: ...")
}

then we wouldn't need to modify anything outside of the cli command or use any mutexes or anything

jdx avatar Jan 29 '24 17:01 jdx

then we wouldn't need to modify anything outside of the cli command or use any mutexes or anything

Correct, the only reason to have Mutexes or Channels would be to capture summaries. If there is no appetite for having some kind of summary report I can drop this to the simplest implementation. Really just playing around with possibilities to scope this out.

Ajpantuso avatar Jan 29 '24 17:01 Ajpantuso

After looking at it I feel like hacking a table on to the default output doesn't look right.

@Ajpantuso you're right it looks a bit odd. So i guess we should start small by refining the current inline approach.

roele avatar Jan 29 '24 17:01 roele

@jdx @roele I've reset this back to barebones incorporating some suggestions.

Making it so timings are always displayed would have some implications for testing so leaving the flag in for now.

Ajpantuso avatar Jan 29 '24 18:01 Ajpantuso