-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explain our Categories policy and enforce it using a Validator (#196)
* introduce the concept of ThirdParty category * intorduce new validator that enforces mandatory category policy * add .NET Framework benchmarks to CoreCLR and CoreFX categories * add 3rd party libs benchmarks to ThirdParty category, 0 errors! * add explanation to the docs * code review fixes
- Loading branch information
1 parent
29b47a6
commit 0c626c0
Showing
34 changed files
with
135 additions
and
14 deletions.
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
33 changes: 33 additions & 0 deletions
33
src/benchmarks/micro/Harness/MandatoryCategoryValidator.cs
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,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
// See the LICENSE file in the project root for more information. | ||
|
||
using System.Collections.Generic; | ||
using System.Linq; | ||
using BenchmarkDotNet.Validators; | ||
|
||
namespace MicroBenchmarks | ||
{ | ||
/// <summary> | ||
/// this class makes sure that every benchmark belongs to either a CoreFX, CoreCLR or ThirdParty category | ||
/// for CoreCLR CI jobs we want to run only benchmarks form CoreCLR category | ||
/// the same goes for CoreFX | ||
/// </summary> | ||
public class MandatoryCategoryValidator : IValidator | ||
{ | ||
public static readonly IValidator FailOnError = new MandatoryCategoryValidator(); | ||
|
||
public bool TreatsWarningsAsErrors => true; | ||
|
||
public IEnumerable<ValidationError> Validate(ValidationParameters validationParameters) | ||
=> validationParameters.Benchmarks | ||
.Where(benchmark => !benchmark.Descriptor.Categories.Any(category => category == Categories.CoreFX || category == Categories.CoreCLR || category == Categories.ThirdParty)) | ||
.Select(benchmark => benchmark.Descriptor.GetFilterName()) | ||
.Distinct() | ||
.Select(benchmarkId => | ||
new ValidationError( | ||
isCritical: TreatsWarningsAsErrors, | ||
$"{benchmarkId} does not belong to one of the mandatory categories: {Categories.CoreCLR}, {Categories.CoreFX}, {Categories.ThirdParty}. Use [BenchmarkCategory(Categories.$)]") | ||
); | ||
} | ||
} |
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
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
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
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
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
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
Oops, something went wrong.