Skip to content

Commit 05a5378

Browse files
committed
Manually separate OR filter patterns
1 parent 61beb50 commit 05a5378

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

Runner/Jobs/BenchmarkLibrariesJob.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,15 @@ private async Task RunBenchmarksAsync(string[] coreRunPaths)
274274
string filter = FilterNameRegex().Match(CustomArguments).Groups[1].Value;
275275
filter = filter.Trim().Trim('`').Trim();
276276

277-
if (!string.IsNullOrWhiteSpace(filter) && !filter.Contains('*'))
278-
{
279-
filter = $"*{filter}*";
280-
}
277+
// A single benchmark argument may combine several glob patterns with '|', e.g.
278+
// "*Perf_Strings*|*Perf_Basic*|*WriteJson*". BenchmarkDotNet's glob filter does NOT treat
279+
// '|' as an OR operator (it Regex.Escape's the pattern, so '|' becomes a literal that never
280+
// matches a benchmark name), but passing multiple space-separated patterns to --filter does
281+
// OR them together. Split on '|' and emit each pattern separately, wrapping any bare pattern
282+
// (one without a '*') with '*...*' as before.
283+
filter = string.Join(' ', filter
284+
.Split('|', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries)
285+
.Select(part => part.Contains('*') ? part : $"*{part}*"));
281286

282287
int dotnetVersion = DotnetHelpers.GetDotnetVersion("performance");
283288

@@ -398,7 +403,7 @@ await RunProcessAsync("/usr/lib/dotnet/dotnet",
398403
await UploadTextArtifactAsync("results.md", combinedMarkdown);
399404
}
400405

401-
[GeneratedRegex(@"^benchmark ([^ ]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline)]
406+
[GeneratedRegex(@"^benchmark\s+(\S+)", RegexOptions.IgnoreCase | RegexOptions.Singleline)]
402407
private static partial Regex FilterNameRegex();
403408

404409
// @MihuBot benchmark GetUnicodeCategory https://github.com/dotnet/runtime/compare/4bb0bcd9b5c47df97e51b462d8204d66c7d470fc...c74440f8291edd35843f3039754b887afe61766e

0 commit comments

Comments
 (0)