forked from dotnet/performance
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add VSTest Adapter and update BenchmarkDotNet (dotnet#3940)
* Add VSTest Adapter * Only use assembly config if in VSTest * Use Entry Assembly, not Calling Assembly
- Loading branch information
1 parent
4f67334
commit c3e96e6
Showing
3 changed files
with
32 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; } | ||
} | ||
} |