Skip to content

Commit

Permalink
Add VSTest Adapter and update BenchmarkDotNet (dotnet#3940)
Browse files Browse the repository at this point in the history
* Add VSTest Adapter

* Only use assembly config if in VSTest

* Use Entry Assembly, not Calling Assembly
  • Loading branch information
caaavik-msft authored Feb 20, 2024
1 parent 4f67334 commit c3e96e6
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PropertyGroup>
<MicrosoftNETILLinkTasksVersion>9.0.0-preview.2.24119.7</MicrosoftNETILLinkTasksVersion>
<MicrosoftNETILLinkPackageVersion>9.0.0-preview.2.24119.7</MicrosoftNETILLinkPackageVersion>
<BenchmarkDotNetVersion>0.13.11-nightly.20231126.107</BenchmarkDotNetVersion>
<BenchmarkDotNetVersion>0.13.13-nightly.20240213.132</BenchmarkDotNetVersion>
<SystemThreadingChannelsPackageVersion>9.0.0-preview.2.24119.7</SystemThreadingChannelsPackageVersion>
<MicrosoftExtensionsLoggingPackageVersion>9.0.0-preview.2.24119.7</MicrosoftExtensionsLoggingPackageVersion>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/benchmarks/micro/MicroBenchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

<!-- Allow building with one major version, and running using a sdk with a higher major version -->
<RollForward Condition="'$(BuildingForWasm)' == 'true'">LatestMajor</RollForward>
<GenerateProgramFile>false</GenerateProgramFile>
</PropertyGroup>

<!-- out-of-band packages that are not included in NetCoreApp have TFM-specific versions -->
Expand Down Expand Up @@ -60,6 +61,7 @@
</Otherwise>
</Choose>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet.TestAdapter" Version="$(BenchmarkDotNetVersion)" />
<PackageReference Include="Jil" Version="3.0.0-alpha2" />
<PackageReference Include="MessagePack" Version="1.9.11" />
<PackageReference Include="MessagePackAnalyzer" Version="1.7.3.7" />
Expand All @@ -73,6 +75,7 @@
<PackageReference Include="Microsoft.Extensions.Logging" Version="$(ExtensionsVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="$(ExtensionsVersion)" />
<PackageReference Include="Microsoft.Extensions.Primitives" Version="$(ExtensionsVersion)" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="protobuf-net" Version="3.0.73" />
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemVersion)" />
<PackageReference Include="System.Drawing.Common" Version="$(SystemVersion)" Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' And '$(_TargetFrameworkVersionWithoutV)' &lt; '8.0'" />
Expand Down
28 changes: 28 additions & 0 deletions src/benchmarks/micro/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.IO;
using System;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Extensions;
using System.Collections.Immutable;
using System.Reflection;

[assembly: MicroBenchmarks.VSTestConfigSource]

namespace MicroBenchmarks
{
[AttributeUsage(AttributeTargets.Assembly)]
class VSTestConfigSourceAttribute : Attribute, IConfigSource
{
public VSTestConfigSourceAttribute()
{
// We only want to set an assembly-level config when it isn't being set by the entry point
// We check for this by seeing if the calling assembly is the same as the executing assembly
Config = Assembly.GetEntryAssembly() == Assembly.GetExecutingAssembly()
? ManualConfig.CreateEmpty()
: RecommendedConfig.Create(
artifactsPath: new DirectoryInfo(Path.Combine(AppContext.BaseDirectory, "BenchmarkDotNet.Artifacts")),
mandatoryCategories: ImmutableHashSet.Create(Categories.Libraries, Categories.Runtime, Categories.ThirdParty));
}

public IConfig Config { get; }
}
}

0 comments on commit c3e96e6

Please sign in to comment.