Skip to content

feat(patch): Add option to run benchmarks in debug mode#343

Merged
hassila merged 6 commits intoordo-one:mainfrom
ptoffy:debug-mode-benchmarks
Jan 20, 2026
Merged

feat(patch): Add option to run benchmarks in debug mode#343
hassila merged 6 commits intoordo-one:mainfrom
ptoffy:debug-mode-benchmarks

Conversation

@ptoffy
Copy link
Copy Markdown
Contributor

@ptoffy ptoffy commented Jan 19, 2026

Description

This adds the option to run benchmarks in debug mode (the benchmark tool is still built in release mode). More specifically, a --debug-mode flag is added that can be passed to the benchmark tool to build the benchmark targets in debug mode. Default is still release.

I'm not precious about the --debug-mode syntax and I can appreciate this can conflict with the --debug one so I'm happy to change this to something else if needed. I also considered --build-mode {release,debug}

How Has This Been Tested?

No tests have been added but happy to add some if needed

Minimal checklist:

  • I have performed a self-review of my own code
  • I have added DocC code-level documentation for any public interfaces exported by the package
  • I have added unit and/or integration tests that prove my fix is effective or that my feature works

@ptoffy ptoffy changed the title Add option to run benchmarks in debug mode feat: Add option to run benchmarks in debug mode Jan 19, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a --debug-mode flag to the benchmark command plugin, allowing users to run benchmarks in debug mode while keeping the benchmark tool itself built in release mode.

Changes:

  • Added --debug-mode command-line flag to enable debug mode for benchmark targets
  • Updated build configuration to use either debug or release mode based on the flag
  • Added documentation for the new flag in help text and documentation

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Sources/Benchmark/Documentation.docc/RunningBenchmarks.md Added documentation for the new --debug-mode flag
Plugins/BenchmarkCommandPlugin/BenchmarkPlugin+Help.swift Added help text for the --debug-mode flag
Plugins/BenchmarkCommandPlugin/BenchmarkCommandPlugin.swift Implemented the debug mode flag extraction and build configuration logic

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hassila hassila changed the title feat: Add option to run benchmarks in debug mode feat(patch): Add option to run benchmarks in debug mode Jan 19, 2026
@hassila
Copy link
Copy Markdown
Contributor

hassila commented Jan 19, 2026

Maybe the logical thing would be to use -c debug / -c release to match SwiftPM?

@supersonicbyte
Copy link
Copy Markdown
Contributor

Maybe the logical thing would be to use -c debug / -c release to match SwiftPM?

+1

@ptoffy
Copy link
Copy Markdown
Contributor Author

ptoffy commented Jan 19, 2026

@hassila @supersonicbyte It seems like PackagePlugin.ArgumentExtractor doesn't support shorthand arguments? I've added --configuration for clarity for now. Let me know if you prefer -c explicitly!

@MahdiBM
Copy link
Copy Markdown
Contributor

MahdiBM commented Jan 19, 2026

I'd just do both to keep it similar to SwiftPM even if it's not very elegant in code 🙂.

@hassila
Copy link
Copy Markdown
Contributor

hassila commented Jan 20, 2026

Oh, you are right PackagePlugin.ArgumentExtractor don't support single-dash arguments unfortunately.

Having slept on it, I'd probably would go with something benchmark-build-configuration instead after all.

Even though it at first glance would be nice to mimic SPM, It might be a bit confusing to see:

swift package -c release benchmark --c debug xyz...

which would be a valid command line - the long form would be more distinct:

swift package -c release benchmark --benchmark-build-configuration debug xyz...

Simply due to us living in the same command line space as SPM here and the position matters, which can make it a bit unclear.

@ptoffy
Copy link
Copy Markdown
Contributor Author

ptoffy commented Jan 20, 2026

I agree!

@hassila hassila merged commit fc19213 into ordo-one:main Jan 20, 2026
13 of 15 checks passed
@hassila
Copy link
Copy Markdown
Contributor

hassila commented Jan 20, 2026

Looks good, thanks for the contribution!

@ptoffy ptoffy deleted the debug-mode-benchmarks branch January 21, 2026 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants