Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to specify benchmark description in outputs #2386

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Editing src/BenchmarkDotNet/Running/BenchmarkConverter.cs for the ada…
…ptive description and removing only methods attribute from BenchmarkDescriptionAttribute
Nepp3r committed Jul 27, 2023
commit 5282284b02833af034d8735861d2e005ccf7eb19
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@

namespace BenchmarkDotNet.Attributes
{
[AttributeUsage(AttributeTargets.Class)]
public class BenchmarkDescriptionAttribute : Attribute
{
public BenchmarkDescriptionAttribute(){ }
9 changes: 7 additions & 2 deletions src/BenchmarkDotNet/Running/BenchmarkConverter.cs
Original file line number Diff line number Diff line change
@@ -127,8 +127,10 @@ private static IEnumerable<Descriptor> GetTargets(
GetTargetedMatchingMethod(methodInfo, iterationSetupMethods),
GetTargetedMatchingMethod(methodInfo, iterationCleanupMethods),
methodInfo.ResolveAttribute<BenchmarkAttribute>(),
type.ResolveAttribute<BenchmarkDescriptionAttribute>(),
methodInfo.ResolveAttribute<BenchmarkDescriptionAttribute>(),
targetMethods,
config));
config)) ;
}

private static MethodInfo GetTargetedMatchingMethod(MethodInfo benchmarkMethod, Tuple<MethodInfo, TargetedAttribute>[] methods)
@@ -155,18 +157,21 @@ private static Descriptor CreateDescriptor(
MethodInfo iterationSetupMethod,
MethodInfo iterationCleanupMethod,
BenchmarkAttribute attr,
BenchmarkDescriptionAttribute descClass,
BenchmarkDescriptionAttribute descMethod,
MethodInfo[] targetMethods,
IConfig config)
{
var categoryDiscoverer = config.CategoryDiscoverer ?? DefaultCategoryDiscoverer.Instance;
var description = attr.Description ?? descMethod.Description ?? descClass.Description ?? methodInfo.Name;
var target = new Descriptor(
type,
methodInfo,
globalSetupMethod,
globalCleanupMethod,
iterationSetupMethod,
iterationCleanupMethod,
attr.Description,
description,
baseline: attr.Baseline,
categories: categoryDiscoverer.GetCategories(methodInfo),
operationsPerInvoke: attr.OperationsPerInvoke,