Skip to content

Commit

Permalink
Allow specifying medium/long jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
MihaZupan committed Jun 20, 2024
1 parent d969f6d commit 9c61b50
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Runner/BenchmarkLibrariesJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,35 @@ private async Task CloneRuntimeAndPerformanceAndSetupToolsAsync()
(string repo, string branch) = GetDotnetPerformanceRepoSource();
await RunProcessAsync("git", $"clone --no-tags --depth=1 -b {branch} --progress https://github.com/{repo} performance", logPrefix: "Clone performance");
if (TryGetFlag("medium") || TryGetFlag("long"))
{
string? path = Directory.EnumerateFiles("performance", "*.cs", SearchOption.AllDirectories)
.Where(f => f.EndsWith("RecommendedConfig.cs", StringComparison.Ordinal))
.FirstOrDefault();
if (string.IsNullOrEmpty(path))
{
await LogAsync("Failed to find RecommendedConfig.cs");
}
else
{
string jobType = $"Job.{(TryGetFlag("medium") ? "Medium" : "Long")}Run";
string source = File.ReadAllText(path);
string newSource = RecommendedConfigJobTypeRegex().Replace(source, $"job = {jobType};");
if (source == newSource)
{
await LogAsync("Failed to find the existing Job type");
}
else
{
File.WriteAllText(path, newSource);
await LogAsync($"Replaced Job type with {jobType}");
}
}
}
});

Task setupZipAndWgetTask = RunProcessAsync("apt-get", "install -y zip wget", logPrefix: "Setup zip & wget");
Expand Down Expand Up @@ -229,4 +258,8 @@ await RunProcessAsync("dotnet",
// We want '+|H' to replace it with '+\|H'
[GeneratedRegex(@"([^ \n:\\])\|([^ \n:])")]
private static partial Regex PipeCharInTableCellRegex();

// Matches https://github.com/dotnet/performance/blob/d0d7ea34e98ca19f8264a17abe05ef6f73e888ba/src/harness/BenchmarkDotNet.Extensions/RecommendedConfig.cs#L33-L38
[GeneratedRegex(@"job = Job\..*?;", RegexOptions.Singleline)]
private static partial Regex RecommendedConfigJobTypeRegex();
}

0 comments on commit 9c61b50

Please sign in to comment.