Skip to content

Add System.Diagnostics.Process output-reading benchmarks#5152

Open
Copilot wants to merge 3 commits intomainfrom
copilot/add-process-output-benchmarks
Open

Add System.Diagnostics.Process output-reading benchmarks#5152
Copilot wants to merge 3 commits intomainfrom
copilot/add-process-output-benchmarks

Conversation

Copy link
Contributor

Copilot AI commented Mar 17, 2026

Extends Perf_Process with three benchmarks that measure reading standard output from a child process echoing 1000 lines.

New benchmarks:

  • ReadOutputLineByLine — event-driven via OutputDataReceived + BeginOutputReadLine(); handler removed after exit
  • ReadOutputToEndAsync_ = await StandardOutput.ReadToEndAsync() + await process.WaitForExitAsync(); #if NET gated (not available on Full Framework)
  • ReadOutputToEnd — synchronous _ = process.StandardOutput.ReadToEnd()

Shared setup:

  • s_outputStartInfo: cmd /c for /L %i in (1,1,1000) do @echo Line %i on Windows, sh -c "for i in $(seq 1 1000); do echo Line $i; done" on Unix; RedirectStandardOutput=true, UseShellExecute=false
  • s_ignoreOutputLine: static readonly DataReceivedEventHandler with a static lambda — avoids per-iteration delegate allocation and closure in ReadOutputLineByLine

Results are explicitly discarded via _ = to prevent potential dead code elimination. The async benchmark uses await process.WaitForExitAsync() to avoid mixing sync and async code.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

Copilot AI and others added 2 commits March 17, 2026 08:57
Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

@copilot please address my feedback

…sync

Co-authored-by: adamsitnik <6011991+adamsitnik@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Mar 17, 2026

@copilot please address my feedback

All four suggestions addressed in d3c0529: static lambda, _ = discards for both ReadToEnd calls, and await process.WaitForExitAsync() in the async benchmark.

Copilot AI requested a review from adamsitnik March 17, 2026 09:18
Copy link
Member

@adamsitnik adamsitnik left a comment

Choose a reason for hiding this comment

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

LGTM assuming the CI is going to be green

@adamsitnik adamsitnik marked this pull request as ready for review March 17, 2026 13:55
@adamsitnik adamsitnik enabled auto-merge (squash) March 17, 2026 13:55
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