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
21 changes: 13 additions & 8 deletions test/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@
<ProjectReference Include="..\..\src\Firely.Fhir.Validation.R4\Firely.Fhir.Validation.R4.csproj" />
</ItemGroup>

<ItemGroup Condition="$(DefineConstants.Contains('VALSDK5'))">
<PackageReference Include="Firely.Fhir.Validation.R4" Version="2.7.0" />
<PackageReference Include="Hl7.Fhir.Specification.Data.R4" Version="5.12.1" />
</ItemGroup>

<ItemGroup Condition="$(DefineConstants.Contains('VALSDK6'))">
<PackageReference Include="Firely.Fhir.Validation.R4" Version="2.8.0-alpha-20250905.1" />
<PackageReference Include="Hl7.Fhir.Specification.Data.R4" Version="6.0.0-rc2-20250915.4" />
<PropertyGroup Condition="$(DefineConstants.Contains('VALSDK5'))">
<ValidatorVersion Condition="'$(ValidatorVersion)' == ''">2.7.0</ValidatorVersion>
<SDKVersion Condition="'$(SDKVersion)' == ''">5.12.1</SDKVersion>
</PropertyGroup>

<PropertyGroup Condition="$(DefineConstants.Contains('VALSDK6'))">
<ValidatorVersion Condition="'$(ValidatorVersion)' == ''">2.8.0-alpha-20250905.1</ValidatorVersion>
<SDKVersion Condition="'$(SDKVersion)' == ''">6.0.0-rc2-20250915.4</SDKVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Condition="'$(ValidatorVersion)' != ''" Include="Firely.Fhir.Validation.R4" Version="$(ValidatorVersion)" />
<PackageReference Condition="'$(SDKVersion)' != ''" Include="Hl7.Fhir.Specification.Data.R4" Version="$(SDKVersion)" />
</ItemGroup>

<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
Expand Down
25 changes: 13 additions & 12 deletions test/Benchmarks/Configuration/CrossVersionConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@

public class CrossVersionConfigurationAttribute : Attribute, IConfigSource
{
private record PackageVersion(string Version, string? Constant = null, bool Baseline = false);
private readonly static string[] ALL_VERSIONS = [
"2.7.0",
"2.8.0-alpha-20250905.1"
private record PackageVersion(string ValidatorVersion, string SDKVersion, string? Constant = null, bool Baseline = false);
private readonly static PackageVersion[] ALL_VERSIONS = [
new("2.7.0", "5.12.1"),
new("2.8.0-alpha-20250905.1", "6.0.0-rc2-20250915.4")
];

private const string PACKAGE = "Firely.Fhir.Validation.R4";

public CrossVersionConfigurationAttribute(Type benchmarkType, bool displayGenColumns = false)
{
var attributes = benchmarkType.GetCustomAttributes(typeof(PackageVersionAttribute), false);
var versions = attributes.OfType<PackageVersionAttribute>().Select(x=> new PackageVersion(x.PackageVersion, x.Constant, x.Baseline)).Distinct().ToList();
var versions = attributes.OfType<PackageVersionAttribute>().Select(x => new PackageVersion(x.ValidatorVersion, x.SDKVersion, x.Constant, x.Baseline)).Distinct().ToList();

if (versions.Count == 0)
versions.AddRange(ALL_VERSIONS.Select(x => new PackageVersion(x)));
versions.AddRange(ALL_VERSIONS);

Config = ManualConfig.CreateEmpty()
.AddDiagnoser(new MemoryDiagnoser(new(displayGenColumns)))
Expand All @@ -35,15 +35,15 @@ public CrossVersionConfigurationAttribute(Type benchmarkType, bool displayGenCol

private static IEnumerable<Job> buildJobsFromVersions(IEnumerable<PackageVersion> versions)
{
foreach (var major in versions.ToLookup(x => x.Version[0]+x.Version[2]))
foreach (var major in versions.ToLookup(x => x.SDKVersion[0]))
{
foreach (var version in major)
{
var defConst = version.Constant ?? $"VAL{major.Key}";
var defConst = version.Constant ?? $"VALSDK{major.Key}";
var job = Job.Default
.WithId(version.Version)
.WithId(version.ValidatorVersion)
// will upgrade the version defined in csproj to a specified version
.WithMsBuildArguments($"/p:{PACKAGE}={version}", getArgFor(defConst));
.WithMsBuildArguments($"/p:ValidatorVersion={version.ValidatorVersion}", $"/p:SDKVersion={version.SDKVersion}", getArgFor(defConst));

if (version.Baseline)
yield return job.AsBaseline();
Expand All @@ -63,9 +63,10 @@ static string getArgFor(string constant)
}

[AttributeUsage(AttributeTargets.Class, AllowMultiple = true)]
public class PackageVersionAttribute(string PackageVersion) : Attribute
public class PackageVersionAttribute(string ValidatorVersion, string SDKVersion) : Attribute
{
public string PackageVersion { get; } = PackageVersion;
public string ValidatorVersion { get; } = ValidatorVersion;
public string SDKVersion { get; } = SDKVersion;
public string? Constant { get; set; } = null;
public bool Baseline { get; set; } = false;
}
Expand Down
4 changes: 2 additions & 2 deletions test/Benchmarks/ValidatorBenchmarks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Firely.Sdk.Benchmarks;

[CrossVersionConfiguration(typeof(ValidatorBenchmarks))]
[PackageVersion("2.8.0-alpha-20250905.1", Constant = "VALSDK6")]
[PackageVersion("2.7.0", Constant = "VALSDK5", Baseline = true)]
[PackageVersion("2.8.0-alpha-20250905.1", "6.0.0-rc2-20250915.4", Constant = "VALSDK6")]
[PackageVersion("2.7.0", "5.12.1", Constant = "VALSDK5", Baseline = true)]
// [PackageVersion("2.2.0")]
// [ProjectReference]
public class ValidatorBenchmarks
Expand Down