Skip to content

Reorganize command line interface options/parameters #3182 - #3216

Open
sheddy123 wants to merge 14 commits into
dotnet:masterfrom
sheddy123:issue-3182-profile
Open

Reorganize command line interface options/parameters #3182#3216
sheddy123 wants to merge 14 commits into
dotnet:masterfrom
sheddy123:issue-3182-profile

Conversation

@sheddy123

Copy link
Copy Markdown
Contributor

Issue #3182's
@filzrev based on your suggestions, "I have specified a benchmark profile key from the command line".
A profile is now a job Id, matched with globs, case-insensitively:

dotnet run -c Release -- --filter 'JsonSerialization' --profile debug
dotnet run -c Release -- --filter '*' --profile net8 net9

Ids come from Job.Default.WithId("net8") in code or [SimpleJob(RuntimeMoniker.Net80, id: "net8")].
Job.Id already existed but was only ever used for display, folder names, and ordering, never selection.

Added documentation for the new `--profile` console argument, detailing how to select benchmark jobs by Id, use glob patterns, and distinguish it from `--profiler`. Included code and command-line examples, and updated the options summary.
Added tests to BenchmarkSwitcherTest.cs covering --profile usage: matching job IDs, glob patterns, attribute-defined jobs, error messages for unmatched profiles, and combined profile/filter scenarios. Introduced WithTwoNamedJobAttributes for attribute-based job selection tests.
Introduced JobIdFilterTests to validate filtering benchmarks by job ID, including exact, case-insensitive, glob patterns, and attribute-defined jobs. Tests also verify recording of observed and matched job IDs. Added helper benchmark classes for test scenarios.
Added tests to ensure correct handling of --profile and --filter
arguments in BenchmarkDotNet config parsing. Verified that JobIdFilter
is only added when a profile is specified, profiles are case-insensitive,
and profile filters are not unioned with other filters. Improves test
coverage for command-line argument parsing.
Introduced JobIdFilter in BenchmarkDotNet.Filters to enable filtering benchmarks using job IDs with glob pattern support. The filter tracks observed and matched job IDs, exposes them for reporting, and applies filtering logic via regular expressions in the Predicate method.
Introduced a Profiles command-line option to CommandLineOptions, enabling users to run only jobs with matching Id(s) using glob patterns. Updated help text to clarify its distinction from the Profiler option and added a usage example for --profile.
Ensure JobIdFilter is added when profiles are specified, so job selection by profile is always combined with other filters. Added comments to clarify filter handling logic.
Added TryPrintWrongProfileInfo to clarify when --profile returns no benchmarks, providing targeted error messages and listing available profiles. Integrated this logic into the filtering process and limited displayed profiles to 40. Added necessary using directive for BenchmarkDotNet.Filters.
@filzrev

filzrev commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

This PR appears to provide a filtering feature based on JobId.

It's a bit different feature that I've commented at #3182.
And adding --profile in addition to --profiler seems to be confusing as commented on documentation.

I personally thought it's better to provide --filter-jobid like syntax that similar to xUnit.v3 MTP-mode command line .
https://xunit.net/docs/getting-started/v3/microsoft-testing-platform#enabling-the-command-line-experience

By using --filter-* argument syntax,
It can be easily extend/group filter related command line argument.

Replaced all references to the --profile argument with --filterJobId for filtering benchmark jobs by Id. Updated examples, descriptions, and usage instructions to reflect this change and clarified usage details.
Replaces the --profile option and Profiles property with --filterJobId and FilterJobIds in CommandLineOptions. Updates all references, help text, examples, and filter logic to use the new naming, clarifying that the filter applies to job IDs rather than profiles.
Replaces all usage of the "--profile" argument with "--filterJobId" in test methods, assertions, and log messages. Updates method names and expectations to use "JobId" terminology for consistency across BenchmarkSwitcherTest.cs and ConfigParserTests.cs.
Refactor BenchmarkSwitcher to use "job Id"/"--filterJobId" instead of "profile"/"--profile" throughout variable names, methods, comments, and user messages. Rename MaxDisplayedProfiles to MaxDisplayedJobIds. Update BenchmarkDotNet.slnx to exclude MonoBenchmarks and SharedDiagnosers integration tests from Release builds by default.
@sheddy123

Copy link
Copy Markdown
Contributor Author

@filzrev does this suffice

@filzrev

filzrev commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

It looks good to me about the PR content that adding --filterJobId cli argument.

If there are no other issues, please go ahead and merge it.
I'll expected to add another --filterUid option on another PR.

Note:
Personally, I don't sure whether it's better to add new filter options to CLI options or not.

Original issue's intent is to reorganize command line arguments and reduce options.
So it might be desirable to introduce another integrated filter syntax for --filter

Example

@sheddy123

Copy link
Copy Markdown
Contributor Author

Hi @filzrev thanks for the review

Adding the advantage of adding --filterJobId option is makes the CLI semantics unambiguous, enables distinct error messages, and reflects the real distinction between "which benchmarks?" and "in which jobs?"
In addition, I cannot merge from my end, can you please help with that

@timcassell

Copy link
Copy Markdown
Collaborator

I'm hesitant to merge this. Adding a bunch of different --filter* arguments is smelly. I also am not happy using job ID (I mentioned a while back that it's a bad API). We should probably do something more like job categories, and expand the --filter query instead of new filter arguments like @filzrev suggested.

@sheddy123

Copy link
Copy Markdown
Contributor Author

@timcassell Thanks for the update. I was wondering if this is what you meant:

  • The selection key should be based on job categories rather than the job ID.
  • Adding a Categories property to Job, most likely under MetaMode, since this is metadata and should not affect the job’s execution.
  • Provide WithCategory/WithCategories methods and support an attribute path, mirroring the existing [BenchmarkCategory] approach.

@sheddy123 sheddy123 mentioned this pull request Aug 22, 2026
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.

3 participants