Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions eng/validate-benchmarks.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@ $benchmarkProjects = @(
@{ Project = "src/Razor/src/Compiler/perf/Microbenchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks.Compiler.csproj"; Framework = "net10.0" }
@{ Project = "src/Razor/src/Razor/benchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks/Microsoft.AspNetCore.Razor.Microbenchmarks.csproj"; Framework = "net10.0"; HasValidationMode = $true }
@{ Project = "src/Razor/src/Compiler/perf/Microsoft.AspNetCore.Razor.Microbenchmarks.Generator/Microsoft.AspNetCore.Razor.Microbenchmarks.Generator.csproj"; HasValidationMode = $true }
# Use a representative type to exercise the generated runner build without running the full benchmark suite.
@{ Project = "src/Tools/IdeCoreBenchmarks/IdeCoreBenchmarks.csproj"; Framework = "net10.0"; Filter = "*SegmentedArrayBenchmarks_Indexer*" }

# These projects are excluded because their current benchmark harnesses do not
# complete a Dry validation run in this script's execution model.
# @{ Project = "src/Tools/IdeCoreBenchmarks/IdeCoreBenchmarks.csproj"; Framework = "net10.0" }
# @{ Project = "src/Tools/IdeBenchmarks/IdeBenchmarks.csproj" }
)

Expand Down Expand Up @@ -65,7 +66,8 @@ foreach ($entry in $benchmarkProjects) {

if ($ci) {
# Keep the filter as one argument so PowerShell does not expand '*' into file names.
$args += "--filter=*"
$filter = if ($entry.ContainsKey("Filter")) { $entry["Filter"] } else { "*" }
$args += "--filter=$filter"
}

Write-Host "dotnet $($args -join ' ')"
Expand Down
24 changes: 22 additions & 2 deletions src/Tools/IdeCoreBenchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace IdeCoreBenchmarks
{
internal class Program
{
private const string GlobalPropertiesToRemoveFromProjectReferencesEnvVariableName = "_GlobalPropertiesToRemoveFromProjectReferences";
private const string BenchmarkDotNetOutputProperties = "ArtifactsPath;OutDir;OutputPath;PublishDir";

private class IgnoreReleaseOnly : ManualConfig
{
public IgnoreReleaseOnly()
Expand All @@ -37,10 +40,27 @@ public static string GetRoslynRootLocation([CallerFilePath] string sourceFilePat
return Path.Combine(Path.GetDirectoryName(sourceFilePath), @"..\..\..");
}

private static void Main(string[] args)
private static int Main(string[] args)
{
Environment.SetEnvironmentVariable(RoslynRootPathEnvVariableName, GetRoslynRootLocation());
new BenchmarkSwitcher(typeof(Program).Assembly).Run(args);
// BenchmarkDotNet gives its generated runner a single output directory through global
// MSBuild properties. If those properties flow into Roslyn's multi-targeted project graph,
// different projects and target frameworks share output and intermediate paths, causing
// file-write races and mixed-framework assemblies.
var existingProperties = Environment.GetEnvironmentVariable(GlobalPropertiesToRemoveFromProjectReferencesEnvVariableName);
var propertiesToRemove = string.IsNullOrEmpty(existingProperties)
? BenchmarkDotNetOutputProperties
: $"{existingProperties};{BenchmarkDotNetOutputProperties}";
Environment.SetEnvironmentVariable(
GlobalPropertiesToRemoveFromProjectReferencesEnvVariableName,
propertiesToRemove);

var summaries = new BenchmarkSwitcher(typeof(Program).Assembly).Run(args);
return summaries.Any(summary =>
summary.HasCriticalValidationErrors ||
summary.Reports.Any(report => !report.BuildResult.IsBuildSuccess || !report.AllMeasurements.Any()))
? 1
: 0;
Comment on lines +58 to +63
}
}
}
Loading