Skip to content

Add Duration to process results: how long each program ran - #67

Merged
HalRiveria-Bot merged 1 commit into
mainfrom
feat/duration
Nov 17, 2026
Merged

HalRiveria-Bot merged 1 commit into
mainfrom
feat/duration

Conversation

@HalRiveria-Bot

Copy link
Copy Markdown
Collaborator

There was no way to see how long each program ran, for finding the slow files in a batch, short of timing it yourself.

What changed

Process results get a Duration field: a [TimeSpan] from the program's start to its exit or kill (Process.ExitTime - Process.StartTime, which works the same on both start paths, read before the process is disposed).

  • It leaves out the time a command waited for a slot and any wait for its output afterwards. A program that exits at once while a leftover child holds its output for the stream timeout reads as short, not as the stream timeout.
  • It's on Complete-PkProcess's and Invoke-PkProcessWithTimeout's result (after StreamError), and on each Invoke-PkProcessBatch result (last, after TimedOut).
  • A program killed by -TimeoutSeconds or force-stopped by an abort gets the time it ran. A command that never started, or couldn't start, gets $null, as does a job whose .Proc isn't a Process (a custom starter).

The README lists the field and shows sorting a batch on it. Scripts that Format-Table a result get one more column.

Testing

  • New harness section AY: a ~2 s program reads about 2 s; with output held open for 3 s past a 1 s stream timeout, Duration stays under 0.8 s while the call takes 1 s; with one slot, the second of two 1 s programs reads about 1 s, not 2; a program killed by a 1 s time limit reads about 1 s; in an abort, the force-stopped program gets its time, while one never started and one that couldn't start get $null. All five failed on the old code (no field) and pass now.
  • The result-shape checks include the new field.
  • Full harness passes in fresh processes on Windows PowerShell 5.1 and PowerShell 7 (550 assertions each).

🤖 Generated with Claude Code

Process results now carry Duration, a [TimeSpan] from the program's
start to its exit or kill (Process.ExitTime - Process.StartTime): not the
time it waited for a slot, nor any wait for its output afterwards, so a
program that exits at once while a leftover child holds its output reads
as short. On Complete-PkProcess's and Invoke-PkProcessWithTimeout's
result, and the batch's (last field). A command an abort force-stopped
gets the time it ran; one that never started, $null.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@HalRiveria-Bot
HalRiveria-Bot merged commit f93a4e0 into main Nov 17, 2026
2 checks passed
@HalRiveria-Bot
HalRiveria-Bot deleted the feat/duration branch November 17, 2026 23:54
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